Disable pidfile for celerybeat
Asked Answered
C

3

32

celeryd doesn't require a pidfile, but celerybeat seems to. Is there any way to disable it? I'm using Upstart to manage processes so using a pidfile is redundant.

Cati answered 4/6, 2012 at 4:14 Comment(8)
Have you had any luck disabling the pid file?Deflected
No, even using celeryd -B causes a pid file to be created. I basically gave up and just specified a path to work around permissions constraints on my system.Cati
Ah okay. I've got a similar situation, it's not running as root so it can't save in /var/run or equivalent. I've found this seems to work though: python manage.py celerybeat --schedule=/var/my_app/celerybeat-schedule --pidfile=. I'm running it through Django, not sure if that has an effect. Having an = and then nothing after it appears to stop one being created. Let me know if it helps. Will submit it as an answer if so!Deflected
@michael that works a treat (am also using django-celery).Portage
@Cati I've added my comment (which seems to work) as an answer — would be great if you could accept!Deflected
@Portage Great, glad it works for you. Feel free to up-vote the answer I just posted :-)Deflected
This question is relevant to Docker users as well.Triphibious
This question is relevant for Heroku users as well, since we're not supposed to write anything on the filesystem, because dynos often restart, always with an empty filesystem.Jointly
D
80

The following seems to have worked for a few people so I'm submitting it as the answer:

python manage.py celerybeat --pidfile= --schedule=/var/my_app/celerybeat-schedule

--pidfile= (an empty string as the pidfile arg) seems to stop one being created.

Deflected answered 16/7, 2013 at 10:33 Comment(4)
Very great tip for avoid CeleryBeat to create PID file before see he must create a another in Django confComfrey
Wanted to mention that I just tried this on supervisor and it works like a charm :)Cathee
Perfect solution!Fosterfosterage
works for me! great for using celery inside Docker.Phrenology
L
3

So for me, I ammended the following in my development docker-compose.yml file:

web
    ...
    command: bash -c "python3 manage.py makemigrations && python3 manage.py migrate --run-syncdb && python3 manage.py runserver 0.0.0.0:8982"

to:

web
    ...
    command: bash -c "rm -rf celerybeat.pid && python3 manage.py makemigrations && python3 manage.py migrate --run-syncdb && python3 manage.py runserver 0.0.0.0:8982"

I'm sure there is a more elegant way of cleaning up this file on startup or even shutdown?

Laruelarum answered 22/1, 2020 at 14:35 Comment(0)
B
3

Deleting celerybeat.pid from base directory helped me fixed this issue enter image description here

Brace answered 22/5, 2021 at 14:6 Comment(1)
This worked for me for docker-compose environment.Graycegrayheaded

© 2022 - 2024 — McMap. All rights reserved.