Ankit
Ankit

Reputation: 4710

Celery worker exited prematurely on restart using systemd

I'm using celery with systemd. I noticed that most times on restart, I lose the workers mid-task. From the celery multi documentation, it seems like the celery multi stopwait should be waiting for the tasks to finish.

Got the following error on restart:

Process "ForkPoolWorker-10" pid:16902 exited with "signal 15 (SIGTERM)"

celery.conf

[Unit]
Description=Celery background worker
After=network.target

[Service]
Type=forking
User=celery
Group=celery
WorkingDirectory=/src

ExecStart=celery multi start worker -A main.celery -Q celery --logfile=/data/celery.log --loglevel=info --concurrency=10 --pidfile=/var/run/celery/%%n.pid

ExecStop=celery multi stopwait worker --pidfile=/var/run/celery/%%n.pid

[Install]
WantedBy=multi-user.target

I also read the systemd documentation, we should at least be waiting 90 seconds for the task to be completed before sending out a SIGTERM. I receive this error in less than 10 seconds of running the restart command.

What am I doing wrong?

Using celery version: 5.2.2 (dawn-chorus)

Upvotes: 0

Views: 344

Answers (0)

Related Questions