Python编程:使用supervisor管理Django-Celery进程

版权声明:本文为博主原创文章,欢迎转载,请注明出处 https://blog.csdn.net/mouday/article/details/88080013

supervisor 进程管理工具

安装

python2

pip install supervisor

配置

$ mkdir config

# 生成配置文件
$ echo_supervisord_conf > config/supervisord.conf

修改配置文件 config/supervisord.conf

1、开启web管理界面:inet_http_server
2、开启管理:supervisorctl.serverurl
3、开启配置文件:include

[include]
files = *.ini

新建日志 logs文件夹

配置3个进程管理文件

1、supervisor_celery_worker.ini

[program:celery-worker]
command=python manage.py celery worker -l INFO
directory=celery_learn/celery_project
environment=PATH="/.virtualenvs/py3/bin"
stdout_logfile=celery_learn/celery_project/logs/celery.worker.log
stderr_logfile=celery_learn/celery_project/logs/celery.worker.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=60
priority=998

2、supervisor_celery_beat.ini

[program:celery-worker]
command=python manage.py celery beat -l INFO
directory=celery_learn/celery_project
environment=PATH="/.virtualenvs/py3/bin"
stdout_logfile=celery_learn/celery_project/logs/celery.beat.log
stderr_logfile=celery_learn/celery_project/logs/celery.beat.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=60
priority=997

3、supervisor_celery_flower.ini

[program:celery-worker]
command=python manage.py celery flower
directory=celery_learn/celery_project
environment=PATH="/.virtualenvs/py3/bin"
stdout_logfile=celery_learn/celery_project/logs/celery.flower.log
stderr_logfile=celery_learn/celery_project/logs/celery.flower.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=60
priority=996

启动

supervisord -c config/supervisord.conf

管理工具

> supervisorctl
> help
> update   # 更新配置文件

管理界面
http://127.0.0.1:9001/

配置参数参考:
http://www.supervisord.org/configuration.html#program-x-section-settings

没有更多推荐了,返回首页