Skip to content

Instantly share code, notes, and snippets.

@akostylev0
Created May 14, 2012 11:16
Show Gist options
  • Save akostylev0/2693413 to your computer and use it in GitHub Desktop.
Save akostylev0/2693413 to your computer and use it in GitHub Desktop.
service tornading
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/python
ARGS="/home/manage/web/$2/deploy/tornading.py"
PID_PATH=/home/manage/web/$2/deploy/$2.pid
NAME=tornading
DESC=tornading
APPS=`ls /home/manage/web/`
if [ $# -eq "2" ]; then
APPS=$2
fi
echo $APPS
for i in $APPS; do
ARGS="/home/manage/web/$i/deploy/tornading.py"
PID_PATH=/home/manage/web/$i/deploy/$i.pid
case "$1" in
start)
echo -n "Starting $DESC $i: "
start-stop-daemon --start --quiet --pidfile $PID_PATH -b --make-pidfile --exec $DAEMON $ARGS
echo "$NAME $i"
;;
stop)
echo -n "Stopping $DESC $i: "
start-stop-daemon --stop --quiet --pidfile $PID_PATH --verbose
echo "$NAME $i"
;;
restart|force-reload)
echo -n "Restarting $DESC $i: "
start-stop-daemon --stop --quiet --pidfile $PID_PATH --verbose
sleep 1
start-stop-daemon --start --quiet --pidfile $PID_PATH -b --make-pidfile --exec $DAEMON $ARGS
echo "$NAME $i"
;;
status)
status_of_proc -p $PID_PATH && exit 0 || exit &?
;;
*)
echo "Usage $NAME {start|stop|restart|status} {app}" >&2
exit 1
;;
esac
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment