File tree Expand file tree Collapse file tree 2 files changed +24
-16
lines changed
Expand file tree Collapse file tree 2 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -495,3 +495,22 @@ def counter_daily():
495495 raise
496496 finally :
497497 db .session .close ()
498+
499+
500+ # Beat schedule for CMDB tasks
501+ from celery .schedules import crontab
502+
503+ CMDB_BEAT_SCHEDULE = {
504+ 'cmdb-counter-main' : {
505+ 'task' : 'cmdb.counter_main' ,
506+ 'schedule' : crontab (minute = '*' ),
507+ },
508+ 'cmdb-counter-adc' : {
509+ 'task' : 'cmdb.counter_adc' ,
510+ 'schedule' : crontab (minute = '*/5' ),
511+ },
512+ 'cmdb-counter-daily' : {
513+ 'task' : 'cmdb.counter_daily' ,
514+ 'schedule' : crontab (hour = 0 , minute = 0 ),
515+ },
516+ }
Original file line number Diff line number Diff line change 22
33from api .app import create_app
44from api .extensions import celery
5- from celery .schedules import crontab
65
76# celery -A celery_worker.celery worker -l DEBUG -E -Q xxxx
87
98app = create_app ()
109app .app_context ().push ()
1110
12- # Beat schedule configuration
13- celery .conf .beat_schedule = {
14- 'cmdb-counter-main' : {
15- 'task' : 'cmdb.counter_main' ,
16- 'schedule' : crontab (minute = '*' ),
17- },
18- 'cmdb-counter-adc' : {
19- 'task' : 'cmdb.counter_adc' ,
20- 'schedule' : crontab (minute = '*/5' ),
21- },
22- 'cmdb-counter-daily' : {
23- 'task' : 'cmdb.counter_daily' ,
24- 'schedule' : crontab (hour = 0 , minute = 0 ),
25- },
26- }
11+ # Load beat schedules from all modules
12+ from api .tasks .cmdb import CMDB_BEAT_SCHEDULE
13+
14+ celery .conf .beat_schedule = celery .conf .get ('beat_schedule' , {})
15+ celery .conf .beat_schedule .update (CMDB_BEAT_SCHEDULE )
You can’t perform that action at this time.
0 commit comments