35 lines
762 B
Python
35 lines
762 B
Python
from __future__ import annotations
|
|
|
|
from celery import Celery
|
|
|
|
from app.core.config import settings
|
|
|
|
|
|
celery_app = Celery(
|
|
"connecthub",
|
|
broker=settings.redis_url,
|
|
backend=settings.redis_url,
|
|
)
|
|
|
|
celery_app.conf.update(
|
|
task_serializer="json",
|
|
accept_content=["json"],
|
|
result_serializer="json",
|
|
enable_utc=False,
|
|
timezone="Asia/Shanghai",
|
|
# 明确包含 task 模块,避免 autodiscover 找不到(也避免导入导致循环依赖)
|
|
include=[
|
|
"app.tasks.execute",
|
|
"app.tasks.dispatcher",
|
|
],
|
|
beat_schedule={
|
|
"connecthub-dispatcher-tick-every-minute": {
|
|
"task": "connecthub.dispatcher.tick",
|
|
"schedule": 60.0,
|
|
}
|
|
},
|
|
worker_redirect_stdouts=False
|
|
)
|
|
|
|
|