I wrote a post about how to run celery as daemon and it has many steps to do, many files to copy to your server, configure permissions, and configure upstart, but after sometime I found another and easier way to daemonize Celery.
In this method we will use supervisor to daemonize Celery, and this can be achieved by 3 simple steps, so let's do it.
sudo apt-get install supervisor on Ubuntu server. For other OSs please visit the official documentation
This is the most important step, and in this step we will create supervisor configuration file to daemonize Celery.
Supervisor Configuration File
Celery project provide the basic configuration file in their Github repository.
Supervisor configuration files live in
Celery official configuration file
; ================================== ; celery worker supervisor example ; ================================== [program:celery] ; Set full path to celery program if using virtualenv command=celery worker -A proj --loglevel=INFO directory=/path/to/project user=nobody numprocs=1 stdout_logfile=/var/log/celery/worker.log stderr_logfile=/var/log/celery/worker.log autostart=true autorestart=true startsecs=10 ; Need to wait for currently executing tasks to finish at shutdown. ; Increase this if you have very long running tasks. stopwaitsecs …