Search code examples
djangodockercelerycelerybeatdjango-celery-beat

Permission denied error with django-celery-beat despite --schedulers flag


I am running Django, Celery, and RabbitMQ in a Docker container.

It's all configured well and running, however when I am trying to install django-celery-beat I have a problem initialising the service.

Specifically, this command:

celery -A project beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler

Results in this error:

celery.platforms.LockFailed: [Errno 13] Permission denied: '/usr/src/app/celerybeat.pid'

When looking at causes/solutions, the permission denied error appears to occur when the default scheduler (celery.beat.PersistentScheduler) attempts to track of the last run times in a local shelve database file and doesn't have write access.

However, I am using django-celery-beat and appying the --scheduler flag to use the django_celery_beat.schedulers service that should store the schedule in the Django database and therefore not require write access.

What else could be causing this problem? / How can I debug this further?


Solution

  • celerybeat (celery.bin.beat) creates a pid file where it stores process id

    --pidfile
    

    File used to store the process pid. Defaults to celerybeat.pid.

    The program won’t start if this file already exists and the pid is still alive.

    You can leave --pidfile= as empty in your command but beware then it will not know if there is more than one celerybeat process active