Skip to content

Instantly share code, notes, and snippets.

@FZambia
Created April 12, 2013 13:23
Show Gist options
  • Save FZambia/5371960 to your computer and use it in GitHub Desktop.
Save FZambia/5371960 to your computer and use it in GitHub Desktop.
start-stop-daemon with tornado example
#!/bin/bash
DAEMON_DIR=/opt/mytornadoapp
DAEMON=$DAEMON_DIR/main.py
NAME=tornado
DESC="tornado daemon"
test -f $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --pidfile /var/run/$NAME.pid \
--chdir $DAEMON_DIR \
--make-pidfile --background -c nobody --startas $DAEMON
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --oknodo \
--pidfile /var/run/$NAME.pid
rm -f /var/run/$NAME.pid
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --oknodo \
--pidfile /var/run/$NAME.pid
rm -f /var/run/$NAME.pid
start-stop-daemon --start --pidfile /var/run/$NAME.pid \
--chdir $DAEMON_DIR \
--make-pidfile --background -c nobody --startas $DAEMON
echo "$NAME."
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment