From aba4933a954e5f420fb64fee5565ccc8a8522694 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 25 May 2026 21:09:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(celery):=20=E6=B7=BB=E5=8A=A0=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E6=B8=85=E7=90=86=E8=BF=87=E6=9C=9F=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- diary_family/celery.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/diary_family/celery.py b/diary_family/celery.py index a5d54c7..00bbadc 100644 --- a/diary_family/celery.py +++ b/diary_family/celery.py @@ -1,6 +1,7 @@ import os from celery import Celery from django.conf import settings +from celery.schedules import crontab # 设置默认的Django设置模块 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'diary_family.settings') @@ -14,6 +15,14 @@ app.config_from_object('django.conf:settings', namespace='CELERY') # 自动发现任务 app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) +# Celery Beat 周期任务配置 +app.conf.beat_schedule = { + 'cleanup-expired-temp-files': { + 'task': 'core.tasks.cleanup_expired_temp_files', + 'schedule': crontab(minute=0), # 每小时整点执行 + }, +} + @app.task(bind=True) def debug_task(self): """调试任务"""