How to stop celery worker?

16,270

There's no way to stop the worker with celery multi command. You can get PID from pid file or from ps output, e.g.

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

or

kill $(cat /path/to/worker.pid)
Share:
16,270

Related videos on Youtube

Grég
Author by

Grég

Updated on September 18, 2022

Comments

  • Grég
    Grég over 1 year

    I am running celery via redis. I start my worker like this:

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

    And I kill it like this:

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

    But the worker is actually still running. I can not start the worker again:

    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
    

    If I kill the process, everything is ok:

    kill 29369
    

    But that is too cumbersome: I need to know the PID. How to really kill the worker with the celery command line tool?

  • Grég
    Grég over 8 years
    What?! According to the celery multi help message, there is a celery multi kill worker1 command. What is that supposed to do but to kill the worker?
  • sartis
    sartis over 8 years
    celery.readthedocs.org/en/latest/userguide/… - it's not documented. I've checked with the source code, it does exactly the same but in python.
  • DejanLekic
    DejanLekic almost 8 years
    That command actually does nothing. Try it and see. After celery multi kill you will still see the processes running...