4

I can't run Celery beat using Docker.

celerybeat_1    | celery.platforms.LockFailed: [Errno 13] Permission 
denied: '/code/celerybeat.pid'

docker service:

celerybeat:
 <<: *django
 depends_on:
  - postgres
  - redis
 command: /start-celerybeat.sh

start-celerybeat.sh

#!/bin/sh

set -o errexit
set -o nounset

celery -A my_project.taskapp beat -l info --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler

How can I fix that?

paul
  • 569
  • 9
  • 13

1 Answers1

12

Delete that file. Then, modify the last line of start-celerybeat.sh, adding --pidfile /tmp/celerybeat.pid to the end

Shinra tensei
  • 1,283
  • 9
  • 21
  • 7
    Just to build on this answer. Celery beat produces 2 files typically (a pid file and a celerybeat-schedule or local database file). You may need to explicitly state where you want these to live. For the pid file use the above recommendation: --pidfile /tmp/celerybeat.pid, for the celerybeat-schedule file use -s /tmp/celerybeat-schedule. Here is the relevant documentation: https://celery.readthedocs.io/en/latest/userguide/periodic-tasks.html#starting-the-scheduler – Taylor D Nov 16 '19 at 18:09
  • @TaylorD you should have posted this as an answer (not a comment). It solved my issue. Thanks! – adhg May 07 '20 at 16:22