fix(automation): 被重启打断的轮次记为 interrupted,不再混进 failed

部署重建容器会打断正在跑的作业,那轮永远写不回结果,由启动时的
cleanup_orphan_runs 收尾。之前收尾成 failed,于是页面上一片红 —— 但这并不是
作业本身的失败:账号侧的 CK 一个没丢(旧 Cookie 已保留),被中断的账号也会按
退避自动重试。混在 failed 里会掩盖真正的失败(如 SQL 语法错误)。

改为独立状态 interrupted,前端用中性灰显示「被中断」,与红色的「失败」区分开。
This commit is contained in:
yml2213
2026-10-02 22:08:18 +08:00
parent df62898d22
commit d6c6113112
3 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -140,7 +140,10 @@ def cleanup_orphan_runs(db: Session, message: str = "服务重启中断") -> int
"""
orphans = db.query(AutomationRun).filter(AutomationRun.status == "running").all()
for run in orphans:
run.status = "failed"
# 用 interrupted 而不是 failed:这不是作业本身的失败(账号侧 CK 没丢、
# 被中断的也会按退避重试),只是进程没了导致那轮没跑完。混进 failed
# 会让页面一片红,掩盖真正的失败。
run.status = "interrupted"
run.finished_at = datetime.now(UTC)
run.message = message
if orphans: