Skip to content

Instantly share code, notes, and snippets.

@winhamwr
Created October 8, 2009 21:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winhamwr/205450 to your computer and use it in GitHub Desktop.
Save winhamwr/205450 to your computer and use it in GitHub Desktop.
Celery /etc/init.d script to keep celeryd running
#!/bin/sh
USER=%(user)s
NAME=celeryd
VIRTUALENV=%(virtualenv_dir)s
PROJECT_ROOT=%(project_root)s
DAEMON=$VIRTUALENV/bin/celeryd
PIDFILE=$PROJECT_ROOT/$NAME.pid
LOGFILE=$PROJECT_ROOT/$NAME.log
[ -x "$DAEMON" ] || echo "Daemon not found at $DAEMON"
[ -x "$DAEMON" ] || exit 0
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --retry 10 --pidfile $PIDFILE --user $USER
rm -f $PIDFILE
}
case "$1" in
start)
echo "Stopping any running daemons..."
do_stop
echo "Starting celeryd..."
su $USER -c "$DAEMON --pidfile $PIDFILE --logfile $LOGFILE --daemon"
;;
stop)
echo "Stopping celeryd..."
do_stop
;;
*)
echo "Usage: $NAME {start|stop}" >&2
exit 3
;;
esac
:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment