此前 restart 硬杀 BG run 线程,下次启动 reaper 把所有 running/cancelling 标 error: server restarted before run finished —— 用户一多就不能随便重启。 单实例止血,零 DB 改动: - lifespan 加 draining(Event) + inflight 登记表(顺手修 create_task 不留引用 可能被 GC 的旧坑);finally 先拒新 run → await 收尾 → 超 drain_timeout 转 协作式 cancel(= 用户按停止,标 idle 不报 error、可重发)→ 超 cancel_grace 仍没退的留给 SIGKILL(最坏退化 = 改前) - POST /messages:draining 期返 503 + Retry-After;起 run 登记 inflight - main.py uvicorn 加 timeout_graceful_shutdown=5(否则长连 SSE 挡在 drain 前) - config/agent.yaml 加 shutdown 段(drain 30s / grace 15s,偏短更安全) - dev SPA chat.js 发送包退避重试(503 背压 + 交接拒连都重试 ~26s) 部署强耦合:unit TimeoutStopSec 10→90(必须 > drain+grace+sandbox 清扫余量), 已写进 RUN.md unit + 故障兜底。B 蓝绿(零 503 窗口)留作触发信号后再做。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| js | ||
| vendor | ||
| dev.html | ||