feat(app): 更新优雅停机逻辑与请求超时设置

- 修改 DrainTimeout 和 ShutdownTimeout 的注释,明确其含义与默认值
- 优化日志信息,提供更清晰的停机状态反馈
- 调整 ShutdownTimeout 默认值为 10s,以增强请求处理的灵活性
- 移除冗余的调试日志代码,提升代码整洁性
This commit is contained in:
2026-04-24 05:43:53 +08:00
parent 0340bc4b8e
commit f22eea72ec
2 changed files with 16 additions and 55 deletions
-39
View File
@@ -275,15 +275,6 @@ func (that *TestApp) GenerateSwagger(title, version, outputDir string) error {
}
isPartialRun := visitedPaths > 0 && visitedPaths < totalPaths
// #region agent log
func() {
if f, err := os.OpenFile("debug-e1b6ef.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
fmt.Fprintf(f, `{"sessionId":"e1b6ef","hypothesisId":"D","message":"partial_run_check","data":{"proj":"%s","totalPaths":%d,"visitedPaths":%d,"isPartialRun":%v}}`+"\n", projName, totalPaths, visitedPaths, isPartialRun)
f.Close()
}
}()
// #endregion
// 仅部分运行时才加载已有 spec 用于合并,全量运行时清空重建
var existingEndpoints map[string]map[string]interface{}
if isPartialRun {
@@ -311,40 +302,10 @@ func (that *TestApp) GenerateSwagger(title, version, outputDir string) error {
// 部分运行且该路径未被访问 → 保留已有 spec 中的数据
if isPartialRun && !visited[apiPath] {
if existing, ok := existingEndpoints[apiPath]; ok {
// #region agent log
if strings.Contains(apiPath, "batch") {
func() {
if f, err := os.OpenFile("debug-e1b6ef.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
fmt.Fprintf(f, `{"sessionId":"e1b6ef","hypothesisId":"D","message":"kept_existing","data":{"path":"%s"}}`+"\n", apiPath)
f.Close()
}
}()
}
// #endregion
endpoints = append(endpoints, existing)
continue
}
// #region agent log
if strings.Contains(apiPath, "batch") {
func() {
if f, err := os.OpenFile("debug-e1b6ef.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
fmt.Fprintf(f, `{"sessionId":"e1b6ef","hypothesisId":"D","message":"NOT_in_existing_file","data":{"path":"%s"}}`+"\n", apiPath)
f.Close()
}
}()
}
// #endregion
}
// #region agent log
if strings.Contains(apiPath, "batch") && isPartialRun && visited[apiPath] {
func() {
if f, err := os.OpenFile("debug-e1b6ef.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
fmt.Fprintf(f, `{"sessionId":"e1b6ef","hypothesisId":"D","message":"regenerated","data":{"path":"%s","numRecs":%d}}`+"\n", apiPath, len(recs))
f.Close()
}
}()
}
// #endregion
httpMethod := "POST"
if len(recs) > 0 && recs[0].Method != "" {