用芹菜部署django项目
Deploy django project with celery
部署好我的django项目后,我只需要触摸uwsgi_touch文件。并且 uwsgi 将优雅地重启它的 worker。但是芹菜呢?现在,当芹菜任务的代码库发生变化时,我只是手动重启芹菜。但即使我手动完成,我仍然不能确定我不会杀死 celery 任务。
有什么解决办法吗?
管理芹菜工人的更好方法是使用supervisor
$ pip install supervisor
$ cd /path/to/your/project
$ echo_supervisord_conf > supervisord.conf
将这些添加到您的 supervisord.conf
文件
[program:celeryworker]
command=/path/to/celery worker -A yourapp -l info
stdout_logfile=/path/to/your/logs/celeryd.log
stderr_logfile=/path/to/your/logs/celeryd.log
现在在终端中使用 supervisord
命令启动主管并使用 supervisorctl
管理进程。
重启你可以做
$ supervisorctl restart celeryworker
我在芹菜常见问题解答中找到了答案
http://docs.celeryproject.org/en/2.2/faq.html#how-do-i-shut-down-celeryd-safely
Use the TERM signal, and the worker will finish all currently
executing jobs and shut down as soon as possible. No tasks should be
lost.
You should never stop celeryd with the KILL signal (-9), unless you’ve
tried TERM a few times and waited a few minutes to let it get a chance
to shut down. As if you do tasks may be terminated mid-execution, and
they will not be re-run unless you have the acks_late option set
(Task.acks_late / CELERY_ACKS_LATE).
部署好我的django项目后,我只需要触摸uwsgi_touch文件。并且 uwsgi 将优雅地重启它的 worker。但是芹菜呢?现在,当芹菜任务的代码库发生变化时,我只是手动重启芹菜。但即使我手动完成,我仍然不能确定我不会杀死 celery 任务。
有什么解决办法吗?
管理芹菜工人的更好方法是使用supervisor
$ pip install supervisor
$ cd /path/to/your/project
$ echo_supervisord_conf > supervisord.conf
将这些添加到您的 supervisord.conf
文件
[program:celeryworker]
command=/path/to/celery worker -A yourapp -l info
stdout_logfile=/path/to/your/logs/celeryd.log
stderr_logfile=/path/to/your/logs/celeryd.log
现在在终端中使用 supervisord
命令启动主管并使用 supervisorctl
管理进程。
重启你可以做
$ supervisorctl restart celeryworker
我在芹菜常见问题解答中找到了答案 http://docs.celeryproject.org/en/2.2/faq.html#how-do-i-shut-down-celeryd-safely
Use the TERM signal, and the worker will finish all currently executing jobs and shut down as soon as possible. No tasks should be lost.
You should never stop celeryd with the KILL signal (-9), unless you’ve tried TERM a few times and waited a few minutes to let it get a chance to shut down. As if you do tasks may be terminated mid-execution, and they will not be re-run unless you have the acks_late option set (Task.acks_late / CELERY_ACKS_LATE).