More convenient way to stop (or restart) a detached celery beat process

celerysystemd

Just to clarify things – I am working on a systemd service file celerybeat.service which should take care of the Celery beat. What I am doing at the moment is calling a script which reads /var/run/celery/celerybeat.pid, kills process with that PID, and then starts Celery beat process again.

Is there a better way to accomplish this?

Best Answer

What we do is we start celery like this (our celery app is in server.py):

python -m server --app=server multi start workername -Q queuename -c 30 --pidfile=celery.pid --beat

Which starts a celery beat process with 30 worker processes, and saves the pid in celery.pid.

Then we can call this to cleanly exit:

celery multi stop workername --pidfile=celery.pid
Related Topic