Run Celery as a daemon with supervisor
First you need to install supervisor.
sudo apt-get install supervisor
Then you’ll need to create the config file:
sudo nao /etc/supervisor/conf.d/celery.conf
And copy these settings:
[program:celery] directory = /home/YOUR_PROJECT/ command = /home/YOUR_PROJECT/venv/bin/celery -A config worker --loglevel=info autostart = true
venv is the virtual environment where you have installed Celery. Running Celery as root is not recommended so you will need to add user=celeryuser or environment=C_FORCE_ROOT=true to the supervisor configuration.
Adding C_FORCE_ROOT is not recommended.
And now you will be able to start/restart/stop celery.
supervisorctl reload supervisorctl start/restart/stop celery