fix:小组件- PUSH

This commit is contained in:
吕新雨
2026-02-03 17:43:58 +08:00
parent d742b398ef
commit c1c2c6197d
66 changed files with 4888 additions and 479 deletions

View File

@@ -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"])