zcbot/web
caoqianming 4f6e879050 feat(web): systemctl restart 优雅 drain in-flight run,不再误标 error
此前 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>
2026-06-10 10:54:43 +08:00
..
static feat(web): systemctl restart 优雅 drain in-flight run,不再误标 error 2026-06-10 10:54:43 +08:00
__init__.py core(§7 Phase G G1): Web UI 脚手架 + cli.py web 子命令 2026-05-14 13:37:54 +08:00
app.py feat(web): systemctl restart 优雅 drain in-flight run,不再误标 error 2026-06-10 10:54:43 +08:00
auth.py feat(dev): 顶栏自助改密码 + 选入按钮文字改图标(防换行) 2026-06-05 15:07:21 +08:00
broker.py core(0004): 删 runs / usage_events 表 + cancel/SSE 改 task-level 2026-05-18 11:05:35 +08:00
pptx_render.py feat(preview): pptx 在线预览 —— LibreOffice→PDF + 复用 PDF iframe(DESIGN §8.3 Stage 1) 2026-06-09 13:04:02 +08:00
sinks.py core(0004): 删 runs / usage_events 表 + cancel/SSE 改 task-level 2026-05-18 11:05:35 +08:00
static_files.py Disable static asset caching 2026-06-08 09:16:31 +08:00