Files
Nexus/server/background/server_batch_reconcile.py
T
Nexus Agent 69068e2e39 feat(ops): server_batch 回收、sync_logs 清理与 Agent 安装跳过
部署对齐三项后端能力:启动/周期收尾僵尸批量任务、30 天推送日志 purge、已安装且版本不低于主站时跳过批量安装 Agent。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 15:23:03 +08:00

28 lines
988 B
Python

"""Background reconciliation for server batch jobs — stuck detection (60s interval)."""
from __future__ import annotations
import asyncio
import logging
from server.application.services.server_batch_service import detect_stuck_batch_jobs
from server.infrastructure.redis.server_batch_store import RECONCILE_INTERVAL_SECONDS
logger = logging.getLogger("nexus.server_batch_reconcile")
async def server_batch_reconcile_loop() -> None:
"""Every minute: auto-finalize batch jobs with no Redis progress for 1h."""
logger.info(
"Server batch reconcile loop started (interval=%ss)",
RECONCILE_INTERVAL_SECONDS,
)
while True:
await asyncio.sleep(RECONCILE_INTERVAL_SECONDS)
try:
stuck = await detect_stuck_batch_jobs()
if stuck:
logger.info("Server batch reconcile: %s stuck job(s) finalized", stuck)
except Exception as e:
logger.error("Server batch reconcile loop error: %s", e)