分批删除,每批 1000 条,删完一批 commit 一次,不会锁表
默认保留 30 天,可通过环境变量 SIGNIN_LOG_RETAIN_DAYS 调整 每天凌晨 3 点执行,错开签到高峰 有完整日志记录删了多少条、截止日期是什么 用独立 engine 避免之前的 event loop 问题
This commit is contained in:
@@ -13,6 +13,7 @@ import sys
|
||||
import logging
|
||||
|
||||
from celery import Celery
|
||||
from celery.schedules import crontab
|
||||
|
||||
# 确保 shared 模块可导入
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../.."))
|
||||
@@ -42,6 +43,10 @@ celery_app.conf.update(
|
||||
"task": "task_scheduler.app.tasks.signin_tasks.check_and_run_due_tasks",
|
||||
"schedule": 60.0, # 每分钟检查一次(轻量查询,只在到期前 5 分钟才真正提交)
|
||||
},
|
||||
"cleanup-old-logs": {
|
||||
"task": "task_scheduler.app.tasks.signin_tasks.cleanup_old_signin_logs",
|
||||
"schedule": crontab(hour=3, minute=0), # 每天凌晨 3 点
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user