typo
#! /bin/sh
# This script starts programs after a server reboot in a way that
# prevents high server load at server startup.
# This script starts typo using mongrel_rails, and nginx
# It removes stale pids
APPDIR=~/typo
PORTDIGITS=$(printf '%03d' $(($UID % 1000))) # 2046 => '046', octal when numeric
MONGPORT=1${PORTDIGITS}0
for ((a=0 ; a < 10 ; a++))
do
PORT=$(($MONGPORT + $a))
if [ -f ${APPDIR}/log/mongrel.$PORT.pid ]
then echo removing stale pidfile ${APPDIR}/log/mongrel.$PORT.pid for pid `cat ${APPDIR}/log/mongrel.$PORT.pid`
rm ${APPDIR}/log/mongrel.$PORT.pid
fi
done
( cd ${APPDIR} && mongrel_rails cluster::start)
( cd ~/ && nginx -c ~/etc/nginx.conf)