1.How to keep celery running with supervisor
Installation
First, you need to install supervisor in your virtualenv and generate a configuration file.
I store a supervisord.conf
config file at the root of each project, and also, be careful to use theabsolute path to the Python interpreter of the virtualenv.
$ pip install supervisor
$ cd /path/to/your/project
$ echo_supervisord_conf > supervisord.conf
Next, just add this section after the [supervisord] section:
[program:celeryd]
command=/home/thomas/virtualenvs/yourvenv/bin/celery worker --app=myapp -l info
stdout_logfile=/path/to/your/logs/celeryd.log
stderr_logfile=/path/to/your/logs/celeryd.logautostart=true
autorestart=true
startsecs=10
stopwaitsecs=600
Usage
$ supervisord
Then, you can use the supervisorctl command to enter the interactive shell. Type help to get started. You can also execute supervisor command directly:
$ supervisorctl tail celeryd
$ supervisorctl restart celeryd
2.How to terminate a supervisord
ps -ef | grep supervisord
You will get some pid of supervisord just like these
root 2503 1 0 Nov19 ? 00:03:23 /usr/bin/python /usr/bin/supervisord
root 21337 2556 0 18:15 pts/8 00:00:00 grep --color=auto supervisord
And the PID is 2503
Then type this:
kill -s SIGTERM 2053
ps -aux|grep supervisor
kill -9 the_pid