supervisor usage

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容