3
votes

I'm trying to make periodic tasks using Celery in my Django project. I'm very struggling to understand how Celery works, and now it started showing something, but I don't know how to stop workers.

At fist, I run this command to start Celery beat.

celery -A proj beat

and then, run this command to start a worker

celery -A proj worker -B

No matter what I do, previous workers are still working. Even though I updated codes and stop the worker with Ctrl+c, they are still running. How can I stop all of them?

[2018-07-25 15:53:49,694: WARNING/ForkPoolWorker-2] Yo
[2018-07-25 15:53:50,224: WARNING/ForkPoolWorker-3] hello
[2018-07-25 15:53:52,694: WARNING/ForkPoolWorker-2] Yo
[2018-07-25 15:53:55,694: WARNING/ForkPoolWorker-3] Yo
[2018-07-25 15:53:58,694: WARNING/ForkPoolWorker-2] Yo
[2018-07-25 15:54:00,227: WARNING/ForkPoolWorker-3] world
[2018-07-25 15:54:00,229: WARNING/ForkPoolWorker-2] hello
1

1 Answers

2
votes

Shutdown should be accomplished using the TERM signal.

Method1:

$ pkill -9 -f 'celery worker'

Method 2:

$ ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9

Official Document: here