Created
May 9, 2018 16:58
-
-
Save jsmolina/2218cc006ce3a9e6faa9b081abde3086 to your computer and use it in GitHub Desktop.
Celery cron (beat) service learned things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Executing a new task periodically in celery like in java quartz, is as simple as: | |
0) Define your tasks in a dictionary (function check_users in background_tasks module will execute every half an hour): | |
beat_schedule = { | |
'check_users': { | |
task: 'backoffice.blueprints.users.background_tasks.check_users' | |
schedule: 1800.0 | |
} | |
} | |
1) Launch scheduler: this scheduler WON'T execute the tasks, it will just schedule them on time. | |
celery -A app.celery beat -s /var/tmp/celerybeat-schedule -l DEBUG --pidfile /var/tmp/celerybeat-pid | |
2) Launch celery workers: this workers will take all celery tasks and run them, including the ones launched from scheduler. | |
celery -A app.celery worker -n worker.main@%h --max-tasks-per-child 5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment