Linux – Trouble running Python Celery as a daemon

daemonlinuxpython

I have Celery setup and running as a daemon on a Ubuntu EC2 instance. This morning I updated some of the tasks and tried to restart Celery and it wasn't working. After working at it a bit I found:

  • Celery will start if I run the command sudo /usr/local/bin/celeryd --time-limit=300 -f /var/log/celeryd.log -l INFO (which is the command that the init script is using).
  • Celery will not run if I run sudo service celeryd start. In this case the startup script will report that it was started and a .pid file will be created in /var/run, but the process does not exist/is stopped.

Are there any hints on how to fix this issue? I reverted all of the changes to both my tasks file and the celeryconfig module, but that did not seem to help it running as a daemon. I'm using the init scripts from the git repo.

Best Answer

The issue in my case was due to file permissions. The celeryconfig and tasks files were not readable by the user I was using for Celery. I figured this out by removing the --background option from the the init.d script and then seeing a Python import error.