如何阻止芹菜工人?

如何阻止芹菜工人?

我透過 redis 運行 celery。我這樣啟動我的工人:

celery multi start worker1 -A mypackage.tasks.tasks
celery multi v3.1.18 (Cipater)
> Starting nodes...
        > [email protected]: OK

我這樣殺掉它:

celery multi kill worker1
celery multi v3.1.18 (Cipater)
> [email protected]: DOWN

但工人實際上仍在運作。我無法再次啟動工作人員:

celery multi start worker1 -A mypackage.tasks.tasks
celery multi v3.1.18 (Cipater)
> Starting nodes...
ERROR: Pidfile (worker1.pid) already exists.
Seems we're already running? (pid: 29369)
        > [email protected]: OK

如果我終止該進程,則一切正常:

kill 29369

但這太麻煩了:我需要知道PID。如何真的用 celery 命令列工具殺死工人?

答案1

沒有辦法用celery multi命令來阻止工人。您可以從 pid 檔案或 ps 輸出中取得 PID,例如

ps auxww | grep '[c]elery worker' | awk '{print $2}' | xargs kill 

或者

kill $(cat /path/to/worker.pid)

相關內容