Celery daemon script not going in background with init script
The celery docs says that
However, in production you probably want to run the worker in the background as a daemon.
I made the init.d script as below
#!/bin/sh
#
# chkconfig: 345 99 15
# description: celery init.d
# Where to chdir at start.
CELERYD_CHDIR="/home/username/django/django_myapp"
# How to call "manage.py celeryd_multi"
CELERYD="/opt/python27/bin/python manage.py celeryd "
#CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"
# Extra arguments to celeryd
CELERYD_OPTS="--time-limit 300 --concurrency=8"
# Name of the celery config module.
CELERY_CONFIG_MODULE="celeryconfig"
# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
# Workers should run as an unprivileged user.
CELERYD_USER="root"
CELERYD_GROUP="celery"
# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="settings"
CELERYD_PIDFILE=/var/run/celery.pid
# Source function library.
. /etc/init.d/functions
# Celery options
CELERYD_OPTS="-B -l info"
if [ -n "$2" ]; then
CELERYD_OPTS="$CELERYD_OPTS $2"
fi
start () {
cd $CELERYD_CHDIR
daemon --user $CELERYD_USER --pidfile $CELERYD_PIDFILE $CELERYD $CELERYD_OPTS &
}
stop () {
if [[ -s $CELERYD_PIDFILE ]] ; then
echo "Stopping Celery"
killproc -p $CELERYD_PIDFILE python
echo "done!"
rm -f $CELERYD_PIDFILE
else
echo "Celery not running."
fi
}
che开发者_如何学编程ck_status() {
status -p $CELERYD_PIDFILE python
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
check_status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
When i execute /etc/init.d/celeryd start
Now it runs fine but again in foreground not in background
IS that the case or i am doing it wrong
精彩评论