-
先推荐一个源,我觉得蛮快的
https://pypi.doubanio.com/simple/](https://pypi.doubanio.com/simple/
-
安装
Supervisor
pip install supervisor
Celery
pip install celery
-
配置Supervisor
在命令行中使用下面命令生成配置文件:
echo_supervisord_conf > /etc/superviso/supervisord.conf
将supervisord.conf做备份:
cp supervisord.conf supervisord.conf.bak
在supervisor目录下创建一个supervisord.conf.d文件夹
mkdir supervisord.conf.d
编辑supervisord.conf,修改最后的include
[include]
files = /etc/supervisor/supervisord.conf.d/*.conf
- Supervisor配置Celery
在* /etc/supervisor/supervisord.conf.d/ * 文件夹里创建一个celeryd_worker.conf:
[program:celeryworker]
command=/srv/www/env/bin/python manage.py celery worker --loglevel=INFO # 启动celery的命令,我用的virtualenv中的python
directory=/srv/www/myapp # 使用celery的项目
numprocs=1
# 设置log的路径
stdout_logfile=/var/log/supervisor/celeryworker.log
stderr_logfile=/var/log/supervisor/celeryworker.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
priority=15
- 启动Celery
Supervisor启动:
./supervisord -c /etc/superviso/supervisord.conf
启动celery:
$sudo ./supervisorctl -c /etc/supervisor/supervisord.conf
supervisor> reread
supervisor> update
supervisor> status
celeryworker RUNNING pid 26172, uptime 2 days, 23:56:29
status 查看状态
reread 读取配置信息
update 加载最新的进程
stop 停止进程
start 启动进程
reload 重新加载配置
网友评论