linux – 正常重启Django Celery实例

前端之家收集整理的这篇文章主要介绍了linux – 正常重启Django Celery实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道重启Celery的最佳方法是什么,而不会在重启期间丢失任何任务.

我目前正在使用芹菜提供的init.d /脚本作为守护程序运行它 – 一切都很好.

尽管如此,我还是需要重新启动它(我认为?)才能看到代码更新.我担心的是,如果有人上传了一张照片,并且我们想在5s左右的窗口中对其进行处理,那么芹菜重新启动任务将永远丢失,我们将开始看到奇怪的问题.

是否有建议的方法来重新加载芹菜的代码而不会在此期间丢失任何交易?

谢谢,

菲尔

解决方法

您可以安全地重新启动芹菜工人,而不会丢失TERM信号的任何任务.所以芹菜将结束当前的任务并死亡.

如果您希望在出现问题时重试您的任务,您还可以使用acks_late选项(Task.acks_late / CELERY_ACKS_LATE).

问:我怎样才能安全地关闭工人?
(来自:http://celery.readthedocs.org/en/latest/faq.html#how-can-i-safely-shut-down-the-worker)

Answer: 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 worker 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).

阻止工人
(来自:http://celery.readthedocs.org/en/latest/userguide/workers.html#worker-stopping)

问:停止工人

Shutdown should be accomplished using the TERM signal.

要发送TERM信号,请使用linux命令KILL
(来自:http://linux.about.com/od/commands/l/blcmdl1_kill.htm)

kill – terminate a process SYNOPSIS

kill [ -s signal | -p ] [ -a ] [ — ] pid … kill -l [ signal ]
DESCRIPTION

The command kill sends the specified signal to the specified process or process group. If no signal is specified,the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes,it may be necessary to use the KILL (9) signal,since this signal cannot be caught.

原文链接:https://www.f2er.com/linux/397019.html

猜你在找的Linux相关文章