Celery does not daemonize itself, please use one of the following daemonization tools.
See the contrib/debian/init.d/ directory in the celery distribution, this directory contains init scripts for celeryd and celerybeat.
These scripts are configured in /etc/default/celeryd.
Usage: | /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status} |
---|---|
Configuration file: | |
/etc/default/celeryd |
To configure celeryd you probably need to at least tell it where to chdir when it starts (to find your celeryconfig).
This is an example configuration for a Python project.
/etc/default/celeryd:
# Where to chdir at start.
CELERYD_CHDIR="/opt/Myproject/"
# Extra arguments to celeryd
CELERYD_OPTS="--time-limit 300"
# Name of the celery config module.#
CELERY_CONFIG_MODULE="celeryconfig"
This is an example configuration for those using django-celery:
# Where the Django project is.
CELERYD_CHDIR="/opt/Project/"
# Path to celeryd
CELERYD="/opt/Project/manage.py celeryd"
# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="settings"
Additional arguments to celeryd, see celeryd --help for a list.
Path to chdir at start. Default is to stay in the current directory.
Full path to the pidfile. Default is /var/run/celeryd.pid.
Full path to the celeryd logfile. Default is /var/log/celeryd.log
Log level to use for celeryd. Default is INFO.
Path to the celeryd program. Default is celeryd. You can point this to an virtualenv, or even use manage.py for django.
User to run celeryd as. Default is current user.
Group to run celeryd as. Default is current user.
Usage: | /etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status} |
---|---|
Configuration file: | |
/etc/default/celerybeat or /etc/default/celeryd |
This is an example configuration for a Python project:
/etc/default/celeryd:
# Where to chdir at start.
CELERYD_CHDIR="/opt/Myproject/"
# Extra arguments to celeryd
CELERYD_OPTS="--time-limit 300"
# Extra arguments to celerybeat
CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
# Name of the celery config module.#
CELERY_CONFIG_MODULE="celeryconfig"
This is an example configuration for those using django-celery:
# Where the Django project is.
CELERYD_CHDIR="/opt/Project/"
# Name of the projects settings module.
DJANGO_SETTINGS_MODULE="settings"
# Path to celeryd
CELERYD="/opt/Project/manage.py celeryd"
# Path to celerybeat
CELERYBEAT="/opt/Project/manage.py celerybeat"
# Extra arguments to celerybeat
CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
Additional arguments to celerybeat, see celerybeat --help for a list.
Full path to the pidfile. Default is /var/run/celeryd.pid.
Full path to the celeryd logfile. Default is /var/log/celeryd.log
Log level to use for celeryd. Default is INFO.
Path to the celeryd program. Default is celeryd. You can point this to an virtualenv, or even use manage.py for django.
User to run celeryd as. Default is current user.
Group to run celeryd as. Default is current user.
If you can’t get the init scripts to work, you should try running them in verbose mode:
$ sh -x /etc/init.d/celeryd start
This can reveal hints as to why the service won’t start.
Also you will see the commands generated, so you can try to run the celeryd command manually to read the resulting error output.
For example my sh -x output does this:
++ start-stop-daemon --start --chdir /opt/Opal/release/opal --quiet \
--oknodo --background --make-pidfile --pidfile /var/run/celeryd.pid \
--exec /opt/Opal/release/opal/manage.py celeryd -- --time-limit=300 \
-f /var/log/celeryd.log -l INFO
Run the celeryd command after --exec (without the --) to show the actual resulting output:
$ /opt/Opal/release/opal/manage.py celeryd --time-limit=300 \
-f /var/log/celeryd.log -l INFO