celeryd init.d

February 9, 2012

I was having trouble getting celeryd to work started from an init.d script. A sample script is provided by the celery project at https://github.com/ask/celery/blob/master/contrib/generic-init.d/celeryd, and I had the following in /etc/default/celeryd:

CELERYD_CHDIR="/home/tjs/web/bbr/bbr"
export DJANGO_SETTINGS_MODULE="settingslive"
ENV_PYTHON="/home/tjs/.virtualenvs/bbr/bin/python"
CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi"
CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryctl"
CELERYD_OPTS=""
CELERYD_LOG_FILE="/var/log/celeryd/%n.log"
CELERYD_LOG_LEVEL="DEBUG"
CELERYD_PID_FILE="/var/run/celeryd/%n.pid"
CELERYD_USER="www-data"
CELERYD_GROUP="www-data"
CELERYD_NODES="cbbr"

The symptoms of the problem were that I could start /etc/init.d/celeryd, and it would tell me that it had worked, but the log file was zero length and ps ax | grep celery showed no processes running.

There were two problems:

  • The version of celery I had (2.4.2) required a patch. bug, patch.
  • The settings file wasn't being picked up properly

For this second point, I had to change the config as follows:

CELERYD_OPTS="--settings=settingslive"

Tags: celery celeryd init.d