-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcelery.py
43 lines (39 loc) · 1.24 KB
/
celery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# your_project/celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
celery_app = Celery('celery_app')
celery_app.config_from_object('django.conf:settings', namespace='CELERY')
celery_app.autodiscover_tasks()
celery_app.conf.beat_schedule = {
'run-daily-task': {
'task': 'apps.tasks.tasks.run_daily_task',
'schedule': crontab(minute=0, hour=0),
},
}
'''
celery_app.conf.beat_schedule = {
'run-critical-task': {
'task': 'apps.tasks.tasks.run_critical_task',
'schedule': crontab(minute='*/5'),
},
'run-hourly-task': {
'task': 'apps.tasks.tasks.run_hourly_task',
'schedule': crontab(minute=0, hour='*/1'),
},
'run-daily-task': {
'task': 'apps.tasks.tasks.run_daily_task',
'schedule': crontab(minute=0, hour=0),
},
'run-weekly-task': {
'task': 'apps.tasks.tasks.run_weekly_task',
'schedule': crontab(minute=0, hour=0, day_of_week='sunday'),
},
'run-monthly-task': {
'task': 'apps.tasks.tasks.run_monthly_task',
'schedule': crontab(minute=0, hour=0, day_of_month='1'),
},
}
'''