From 573aa29f36a19f5dc2c271402960340ea315e0ba Mon Sep 17 00:00:00 2001 From: "mark.tian" Date: Wed, 10 Dec 2025 08:19:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E6=AF=8F=E4=B8=AA=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 4 ++++ app/celery_tasks.py | 3 ++- app/config.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index e72e6d6..3d0ebbe 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,10 @@ DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/ai_talk_callback_ CELERY_BROKER_URL=redis://localhost:6379/0 CELERY_RESULT_BACKEND=redis://localhost:6379/0 +# 任务配置 +ENABLED_PUSH_DATA_TO_DTC_TASK=false +ENABLED_CALL_API_TASK=false + # Flower监控配置 FLOWER_ENABLED=true FLOWER_PORT=5555 diff --git a/app/celery_tasks.py b/app/celery_tasks.py index dda6fa3..4a09131 100644 --- a/app/celery_tasks.py +++ b/app/celery_tasks.py @@ -41,6 +41,7 @@ engine = create_engine( ) @celery_app.task(bind=True, name='push_data_to_dtc') +@conditional_task(enabled=settings.enabled_push_data_to_dtc_task) def push_data_to_dtc_task(self): """ 推送数据给DTC的Celery任务 @@ -221,7 +222,7 @@ def push_data_to_dtc_task(self): @celery_app.task(bind=True, name='call_api', max_retries=None) -@conditional_task(enabled=False) +@conditional_task(enabled=settings.enabled_call_api_task) def execute_call_api_task(self): """遍历API配置文件中的所有API信息并调用接口""" current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') diff --git a/app/config.py b/app/config.py index 39d2dcd..0d1cd1e 100644 --- a/app/config.py +++ b/app/config.py @@ -18,6 +18,10 @@ class Settings(BaseSettings): celery_timezone: str = "Asia/Shanghai" celery_enable_utc: bool = False + # 任务配置 + enabled_push_data_to_dtc_task: bool = False # 是否启用推送数据给DTC的任务 + enabled_call_api_task: bool = False # 是否启用调用API的任务 + # Flower监控配置 flower_enabled: bool = True # 是否启用Flower监控 flower_url: str = "http://localhost:5555" # Flower访问URL