Skip to content

Commit

Permalink
feat(backend): 调整周期任务执行周期 #8342
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Dec 2, 2024
1 parent 605b6f8 commit 6158290
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dbm-ui/backend/db_periodic_task/local_tasks/db_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
logger = logging.getLogger("celery")


@register_periodic_task(run_every=crontab(hour="*/6", minute="0"))
@register_periodic_task(run_every=crontab(hour="0", minute="0"))
def update_local_notice_group():
"""同步告警组"""
dba_ids = DBAdministrator.objects.values_list("id", flat=True)
count = len(dba_ids)
# 同步 DBA 内置告警组
for index, dba_id in enumerate(dba_ids):
countdown = calculate_countdown(count=count, index=index, duration=6 * TimeUnit.HOUR)
countdown = calculate_countdown(count=count, index=index, duration=8 * TimeUnit.HOUR)
logger.info("dba_id({}) update notice group will be run after {} seconds.".format(dba_id, countdown))
with start_new_span(update_dba_notice_group):
update_dba_notice_group.apply_async(kwargs={"dba_id": dba_id}, countdown=countdown)
Expand Down Expand Up @@ -81,7 +81,7 @@ def sync_plat_monitor_policy(action_id=None, db_type=None, force=False):
MonitorPolicy.sync_plat_monitor_policy(action_id=action_id, db_type=db_type, force=force)


@register_periodic_task(run_every=crontab(minute=0, hour="*/1"))
@register_periodic_task(run_every=crontab(minute=0, hour="*/2"))
def sync_plat_dispatch_policy():
"""同步平台分派通知策略
按照app_id->db_type来拆分策略:
Expand All @@ -94,7 +94,7 @@ def sync_plat_dispatch_policy():
count = len(biz_ids)
# 同步平台/业务分派策略
for index, bk_biz_id in enumerate(biz_ids):
countdown = calculate_countdown(count=count, index=index, duration=TimeUnit.HOUR)
countdown = calculate_countdown(count=count, index=index, duration=2 * TimeUnit.HOUR)
logger.info("biz({}) sync dispatch policy will be run after {} seconds.".format(bk_biz_id, countdown))
with start_new_span(sync_biz_dispatch_policy):
sync_biz_dispatch_policy.apply_async(kwargs={"bk_biz_id": bk_biz_id}, countdown=countdown)
Expand Down

0 comments on commit 6158290

Please sign in to comment.