forked from DevOps/deploy.stack
fix: 增加调试输出并调整健康检查超时时间
在配置加载时添加调试信息输出,方便排查问题 将健康检查的超时时间从2秒延长至60秒,避免因网络延迟导致误判
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -21,3 +21,8 @@ logs/
|
|||||||
mcp_server_go/go.sum
|
mcp_server_go/go.sum
|
||||||
mcp_server_go/mcp_server_go
|
mcp_server_go/mcp_server_go
|
||||||
crontab/smartctl_log
|
crontab/smartctl_log
|
||||||
|
crontab/debug_*.py
|
||||||
|
crontab/test_*.py
|
||||||
|
crontab/test*.py
|
||||||
|
g-b/*
|
||||||
|
.gitignore
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ func loadConfig() error {
|
|||||||
return fmt.Errorf("读取配置文件失败: %w", err)
|
return fmt.Errorf("读取配置文件失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打印当前使用的配置文件路径(使用标准库输出,因为logger可能还未初始化)
|
||||||
|
fmt.Printf("成功加载配置文件: %s\n", viper.ConfigFileUsed())
|
||||||
|
|
||||||
if err := viper.Unmarshal(&config); err != nil {
|
if err := viper.Unmarshal(&config); err != nil {
|
||||||
return fmt.Errorf("解析配置文件失败: %w", err)
|
return fmt.Errorf("解析配置文件失败: %w", err)
|
||||||
}
|
}
|
||||||
@@ -280,7 +283,7 @@ func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
oaiHealthy := false
|
oaiHealthy := false
|
||||||
if openaiClient != nil {
|
if openaiClient != nil {
|
||||||
// 创建一个轻量级的测试请求
|
// 创建一个轻量级的测试请求
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
_, err := openaiClient.ListModels(ctx)
|
_, err := openaiClient.ListModels(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user