Created
November 6, 2012 06:44
-
-
Save mokemokechicken/4023082 to your computer and use it in GitHub Desktop.
Sysvinit script sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: gunicorn_scweb | |
# Required-Start: $network $local_fs | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: SimpleCounter Web | |
# Description: Yumemi Inc. | |
#### END INIT INFO | |
NAME=gunicorn_scweb | |
USER=simplecount | |
DEPLOY_DIR="/var/lib/simple_count/simple_counter_web" | |
CMD="${DEPLOY_DIR}/venv/bin/gunicorn_django" | |
CMD_ARGS="-c /etc/gunicorn/simple_counter.py -u $USER scweb" | |
########## Common | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH | |
SSD=start-stop-daemon | |
PID=/var/run/${NAME}.pid | |
start () { | |
echo -n "Start $NAME" | |
. $DEPLOY_DIR/venv/bin/activate | |
$SSD --start --pidfile $PID --make-pidfile --background -d $DEPLOY_DIR/scweb --exec $CMD -- $CMD_ARGS | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
stop () { | |
echo -n "Stop $NAME" | |
$SSD --stop --oknodo --pidfile $PID | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
restart () { | |
stop | |
sleep 1 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
echo "not supported" | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment