feat: 添加通讯录自动同步功能
Some checks failed
continuous-integration/drone/push Build is failing

- 添加 APScheduler 依赖
- 创建定时任务调度模块 scheduler.py
- 增量同步:每30分钟执行
- 完整同步:每天凌晨2点执行
- 添加定时任务管理 API
- 支持环境变量配置同步参数
This commit is contained in:
yuliang_guo
2026-01-29 15:19:20 +08:00
parent 174929d599
commit c97a09de35
6 changed files with 364 additions and 0 deletions

View File

@@ -34,10 +34,29 @@ async def lifespan(app: FastAPI):
logger.info("Redis 初始化成功")
except Exception as e:
logger.warning(f"Redis 初始化失败(非致命): {e}")
# 初始化定时任务调度器
try:
from app.core.scheduler import scheduler_manager
from app.core.database import async_session_factory
await scheduler_manager.init(async_session_factory)
scheduler_manager.start()
logger.info("定时任务调度器启动成功")
except Exception as e:
logger.warning(f"定时任务调度器启动失败(非致命): {e}")
yield
# 关闭时执行
# 停止定时任务调度器
try:
from app.core.scheduler import scheduler_manager
scheduler_manager.stop()
logger.info("定时任务调度器已停止")
except Exception as e:
logger.warning(f"停止定时任务调度器失败: {e}")
try:
from app.core.redis import close_redis
await close_redis()