Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I restart celery workers gracefully?

While issuing a new build to update code in workers how do I restart celery workers gracefully?

Edit: What I intend to do is to something like this.

  • Worker is running, probably uploading a 100 MB file to S3
  • A new build comes
  • Worker code has changes
  • Build script fires signal to the Worker(s)
  • Starts new workers with the new code
  • Worker(s) who got the signal after finishing the existing job exit.
like image 451
Quintin Par Avatar asked Mar 19 '12 04:03

Quintin Par


People also ask

How do I check the status of my Celery worker?

celery -A yourproject. app inspect status will give the status of your workers. celery -A yourproject. app inspect active will give you list of tasks currently running, etc.

What is Apache Celery?

Celery is an open source asynchronous task queue or job queue which is based on distributed message passing. While it supports scheduling, its focus is on operations in real time. Celery. Stable release. 5.2.3 / December 29, 2021.


1 Answers

According to https://docs.celeryproject.org/en/master/userguide/workers.html#restarting-the-worker you can restart a worker by sending a HUP signal

 ps auxww | grep celeryd | grep -v "grep" | awk '{print $2}' | xargs kill -HUP 
like image 105
armonge Avatar answered Sep 23 '22 06:09

armonge