安装
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 # 更新配置文件