🐛 fix(server): 增加优雅退出与请求超时保护
- 新增 SIGINT/SIGTERM 信号处理与 http.Server.Shutdown,退出前确保统计数据保存、数据库正常关闭 - 为 http.Server 设置 ReadHeaderTimeout/ReadTimeout/WriteTimeout/IdleTimeout,防止慢客户端长期占用连接 - 全局配置指针改为 atomic.Pointer 并提供 GetAppConfig 访问器,消除配置热更新时的数据竞争,同时删除冗余的 manager.config 字段 - 请求统计九组计数器重构为 map[string]*atomic.Int64,统一 incrementStat/getStatsSnapshot 访问,精简约 40 行样板代码 - go mod tidy 清理 go.mod 与 go.sum 中的冗余依赖条目
This commit is contained in:
1 parent
6981148727
commit
d710d382ee
12 files changed
+125
-305
No files matched your search
+10
-18
@@ -72,15 +72,7 @@ func HandleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// 获取统计数据
|
||||
total := getTotal()
|
||||
search := getSearch()
|
||||
detail := getDetail()
|
||||
catalog := getCatalog()
|
||||
content := getContent()
|
||||
manga := getManga()
|
||||
audio := getAudio()
|
||||
video := getVideo()
|
||||
category := getCategory()
|
||||
stats := getStatsSnapshot()
|
||||
|
||||
// 获取设备密钥池状态
|
||||
poolStatus := getDeviceKeyPoolStatus()
|
||||
@@ -857,15 +849,15 @@ func HandleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
poolStatus["valid"],
|
||||
poolStatus["invalid"],
|
||||
poolStatus["current_index"],
|
||||
total,
|
||||
search,
|
||||
detail,
|
||||
catalog,
|
||||
content,
|
||||
manga,
|
||||
audio,
|
||||
video,
|
||||
category,
|
||||
stats["total"],
|
||||
stats["search"],
|
||||
stats["detail"],
|
||||
stats["catalog"],
|
||||
stats["content"],
|
||||
stats["manga"],
|
||||
stats["audio"],
|
||||
stats["video"],
|
||||
stats["category"],
|
||||
getDBCacheCount(),
|
||||
getCacheStatus(),
|
||||
getCleanupStatus(),
|
||||
|
||||
Reference in new issue
Block a user