fix:小组件- PUSH
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from celery import Celery
|
||||
from celery.schedules import crontab
|
||||
|
||||
from app.core.config import get_settings
|
||||
|
||||
@@ -38,6 +39,20 @@ celery_app.conf.update(
|
||||
task_default_routing_key=f"{prefix}:celery",
|
||||
)
|
||||
|
||||
# 自动发现任务(app/tasks 下的 shared_task)
|
||||
celery_app.autodiscover_tasks(["app.tasks"])
|
||||
# 定时任务(Celery Beat)
|
||||
# 说明:
|
||||
# - 每天运行一次“生成推送计划”,为所有开启每日提醒的用户生成当天/明天的随机抖动时间点,并投递 ETA 发送任务
|
||||
# - 这里按 UTC 00:10 触发一次;具体时间可按运维习惯调整
|
||||
celery_app.conf.timezone = "UTC"
|
||||
celery_app.conf.beat_schedule = {
|
||||
"push-generate-daily-schedule": {
|
||||
"task": "tasks.push.generate_daily_schedule",
|
||||
"schedule": crontab(minute=10, hour=0),
|
||||
"kwargs": {"max_users": 5000},
|
||||
"options": {"queue": f"{prefix}:celery"},
|
||||
}
|
||||
}
|
||||
|
||||
# 自动发现任务(约定:导入 app.tasks 触发其内部对子模块的显式导入)
|
||||
celery_app.autodiscover_tasks(["app"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user