Created
October 8, 2009 21:55
-
-
Save winhamwr/205450 to your computer and use it in GitHub Desktop.
Celery /etc/init.d script to keep celeryd running
This file contains 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 | |
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