您可以在/etc/supervisor/conf.d/
中写下您的芹菜任务。创建一个像celery.conf
芹菜的新配置文件。
假设你的virtualenv是venv
,Django项目是样品,你的芹菜脚本在_celery.py
这个文件看起来应该像
[program:celery]
command=/home/ubuntu/.virtualenvs/venv/bin/celery --app=sample._celery:app worker --loglevel=INFO
directory=/home/ubuntu/sample/
user=ubuntu
numprocs=1
stdout_logfile=/home/ubuntu/logs/celery-worker.log
stderr_logfile=/home/ubuntu/logs/celery-error.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998
写你需要运行
这监督员程序后,
如果添加管理程序运行这个 $ sudo supervisorctl reread
芹菜:可用
如果添加/更新监督员程序运行此 $ sudo supervisorctl update
芹菜:额外的处理组
要检查你的芹菜任务的状态 $ sudo supervisorctl status celery
芹菜正在进行PID 18020,运行时间〇时00分50秒
要停止芹菜任务 $ sudo supervisorctl stop celery
芹菜:停止
要启动芹菜任务 $ sudo supervisorctl start celery
芹菜:开始
要重新启动芹菜任务(这将停止并重新启动指定的任务) $ sudo supervisorctl restart celery
芹菜:停止 芹菜:开始