chore(logging): 更新日志重定向与捕获功能

- 在 .gitignore 中添加调试日志文件的忽略规则,避免不必要的调试信息被提交
- 修改 application.go 中的 stdout 重定向逻辑,使用 log.CaptureStream 以支持更灵活的日志捕获
- 更新 README 文档,增加对日志重定向功能的说明
This commit is contained in:
2026-07-13 07:45:51 +08:00
parent e14c9742c1
commit 6b689f3a1b
23 changed files with 1316 additions and 1836 deletions
@@ -1,6 +1,6 @@
---
---
name: 优雅停机方案
overview: 在 HoTime 框架层实现优雅停机,跨平台(Windows/Linux)支持。收到信号后新请求立即返回 503 让 nginx 切流,等排空后调用 http.Server.Shutdown 等在途请求完成,exit(0) 退出,run_xbc.cmd 检测正常退出不重启。
overview: 在 HoTime 框架层实现优雅停机,跨平台(Windows/Linux)支持。收到信号后新请求立即返回 503 让 nginx 切流,等排空后调用 http.Server.Shutdown 等在途请求完成,exit(0) 退出,run_app.cmd 检测正常退出不重启。
todos:
- id: framework-core
content: hotimev1.5/application.go:新增 shuttingDown/shutdownOnce/DrainTimeout/ShutdownTimeout 字段,改 ServeHTTP,改 Run() 信号 goroutine,改 recover 保护,提取 initiateGracefulShutdown()
@@ -15,7 +15,7 @@ todos:
content: Nginx location 块加 proxy_next_upstream error timeout http_503 和 proxy_next_upstream_tries 2
status: completed
- id: cmd-exit-check
content: run_xbc.cmd:检测 EXIT_CODE == 0 时不重启直接退出
content: run_app.cmd:检测 EXIT_CODE == 0 时不重启直接退出
status: completed
- id: docs
content: 新建 hotimev1.5/docs/graceful-shutdown.md 文档
@@ -45,7 +45,7 @@ sequenceDiagram
App->>App: server.Shutdown(ShutdownTimeout=30s)
Note over App: 等所有在途请求跑完
App->>OS: os.Exit(0)
Note over Op: run_xbc.cmd 检测 exit 0 → 不重启
Note over Op: run_app.cmd 检测 exit 0 → 不重启
```
## 信号触发场景对照表
@@ -199,7 +199,7 @@ proxy_next_upstream_tries 2;
---
### 5. [`run_xbc.cmd`](d:/work/xbc/run_xbc.cmd)
### 5. [`run_app.cmd`](d:/work/your-app/run_app.cmd)
`goto run_app` 前插入 exit code 判断: