Skip to content

Instantly share code, notes, and snippets.

@williamsjj
Created April 21, 2010 15:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamsjj/373978 to your computer and use it in GitHub Desktop.
Save williamsjj/373978 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Start/stop the named twistd application
#
APP=/opt/myapp/myapp.py
TWISTD=/usr/bin/twistd
PID=/var/run/myapp.pid
LOGFILE=/var/log/myapp/myapp.log
DESCRIPTION="Super duper Twisted apptacularness!"
NAME=myapp
test -f $APP || exit 0
test -f $TWISTD || exit 0
. /lib/lsb/init-functions
case "$1" in
start) log_daemon_msg "Starting $DESCRIPTION" "$NAME"
start-stop-daemon --start --quiet --pidfile $PID --name $NAME --startas $TWISTD -- --logfile="$LOGFILE" --pidfile="$PID" -y $APP
log_end_msg $?
;;
stop) log_daemon_msg "Stopping $DESCRIPTION" "$NAME"
start-stop-daemon --stop --quiet --pidfile $PID
log_end_msg $?
;;
restart) log_daemon_msg "Restarting $DESCRIPTION" "$NAME"
$0 stop
$0 start
log_end_msg $?
;;
*) log_action_msg "Usage: /etc/init.d/$NAME {start|stop|restart}"
exit 2
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment