[稳定性] P2:HTTP 服务补齐超时并支持优雅退出 #46

Closed
opened 2026-10-31 08:38:47 +08:00 by lixu · 1 comment
Owner

现状

公开 API 和后台的 http.Server 只设置了 ReadHeaderTimeout;收到 SIGTERM 直接退出,正在处理的请求(如大批量回流、导入)会被中断。

要求

  • 两个服务设置 ReadTimeout 60s、WriteTimeout 60s、IdleTimeout 120s(保留 ReadHeaderTimeout 10s)。
  • 收到 SIGINT/SIGTERM 后调用 Shutdown,最多等 25 秒,再关闭数据库连接池。
  • docker-compose.prod.yml 的 api/admin 设 stop_grace_period: 30s。

验收

  • 本地启动后发送 SIGTERM,日志显示优雅退出,进程退出码为 0。

来源:只读审查 main@36f9c95(2026-10-23)。

## 现状 公开 API 和后台的 `http.Server` 只设置了 `ReadHeaderTimeout`;收到 SIGTERM 直接退出,正在处理的请求(如大批量回流、导入)会被中断。 ## 要求 - [ ] 两个服务设置 `ReadTimeout 60s`、`WriteTimeout 60s`、`IdleTimeout 120s`(保留 `ReadHeaderTimeout 10s`)。 - [ ] 收到 SIGINT/SIGTERM 后调用 `Shutdown`,最多等 25 秒,再关闭数据库连接池。 - [ ] `docker-compose.prod.yml` 的 api/admin 设 `stop_grace_period: 30s`。 ## 验收 - 本地启动后发送 SIGTERM,日志显示优雅退出,进程退出码为 0。 来源:只读审查 main@36f9c95(2026-10-23)。
lixu closed this issue 2026-10-31 09:45:34 +08:00
Author
Owner

已由 #56 合并(main c163f2b7)。合并前已把最新 main 合入分支,并在本地按 .github/workflows/ci.yml 跑通:Go 1.27.3 的 gofmt/vet/build/test(PostgreSQL 16,后台 DB 测试 0 跳过)、Python ruff/pytest(52 通过)、迁移 up/down、两份 compose config;#46 另做了 SIGTERM 优雅退出验证(退出码 0)。生产尚未部署。

Written by Devin

已由 #56 合并(main c163f2b7)。合并前已把最新 main 合入分支,并在本地按 .github/workflows/ci.yml 跑通:Go 1.27.3 的 gofmt/vet/build/test(PostgreSQL 16,后台 DB 测试 0 跳过)、Python ruff/pytest(52 通过)、迁移 up/down、两份 compose config;#46 另做了 SIGTERM 优雅退出验证(退出码 0)。生产尚未部署。 [Written by Devin](https://app.devin.ai/sessions/e8ebad4bb5c74fe8bf8f4a2c8825de40)
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lixu/goods#46