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.

bradley.ayers
  • 37,165
  • 14
  • 93
  • 99
  • Have you had any luck disabling the pid file? – Michael Waterfall Jun 19 '12 at 17:04
  • 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. – bradley.ayers Jun 19 '12 at 23:45
  • 4
    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! – Michael Waterfall Jun 20 '12 at 10:55
  • @michael that works a treat (am also using django-celery). – Rich Jul 10 '13 at 13:21
  • @bradley.ayers I've added my comment (which seems to work) as an answer — would be great if you could accept! – Michael Waterfall Jul 16 '13 at 10:35
  • @Rich Great, glad it works for you. Feel free to up-vote the answer I just posted :-) – Michael Waterfall Jul 16 '13 at 10:36
  • 5
    This question is relevant to Docker users as well. – Chris Martin Nov 24 '15 at 00:04
  • 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. – David Dahan Oct 17 '18 at 17:04

3 Answers3

79

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.

Michael Waterfall
  • 20,497
  • 27
  • 111
  • 168
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?

Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
3

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

StupidWolf
  • 45,075
  • 17
  • 40
  • 72