Search code examples
pythoncelerysupervisordcelerybeat

setup celerybeat with supervisord


I am confused on how to use celery beat with the supervisord process control system. The following code is an example of a celerybeat program on supervisord.

; ================================
;  celery beat supervisor example
; ================================

[program:celerybeat]
; Set full path to celery program if using virtualenv
command=celery beat -A myapp --schedule /var/lib/celery/beat.db --loglevel=INFO

; remove the -A myapp argument if you are not using an app instance

directory=/path/to/project
user=nobody
numprocs=1
stdout_logfile=/var/log/celery/beat.log
stderr_logfile=/var/log/celery/beat.log
autostart=true
autorestart=true
startsecs=10

; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=999

On the 7th line it has the following code: /var/lib/celery/beat.db, what is this, and what would I replace this path with? Similarily, what would I replace this path with /var/log/celery/beat.log? Thanks.


Solution

  • From the command help: --schedule is:

      -s SCHEDULE, --schedule=SCHEDULE
                        Path to the schedule database. The extension '.db'
                        will be appended to the filename. Default: celerybeat-
                        schedule
    

    And from the docs:

    Custom scheduler classes can be specified on the command-line (the -S argument). The default scheduler is celery.beat.PersistentScheduler, which is simply keeping track of the last run times in a local database file (a shelve).

    django-celery also ships with a scheduler that stores the schedule in the Django database:

    $ celery -A proj beat -S djcelery.schedulers.DatabaseScheduler

    Using django-celery‘s scheduler you can add, modify and remove periodic tasks from the Django Admin.