修复健康检查失败
This commit is contained in:
@@ -18,6 +18,14 @@ type APIHandler struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// HealthCheckHandler 健康检查端点(无需认证)
|
||||
func (h *APIHandler) HealthCheckHandler(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "ok",
|
||||
"timestamp": time.Now().Unix(),
|
||||
})
|
||||
}
|
||||
|
||||
// ModelListResponse 符合OpenAI /v1/models API响应格式
|
||||
type ModelListResponse struct {
|
||||
Object string `json:"object"`
|
||||
|
||||
@@ -39,6 +39,10 @@ func main() {
|
||||
DB: database,
|
||||
}
|
||||
|
||||
// 添加健康检查端点(无需认证)
|
||||
router.GET("/health", handler.HealthCheckHandler)
|
||||
router.GET("/healthz", handler.HealthCheckHandler)
|
||||
|
||||
// 创建根组
|
||||
root_ := router.Group("/")
|
||||
root_.Use(middleware.AuthMiddleware(database))
|
||||
|
||||
@@ -21,7 +21,7 @@ services:
|
||||
networks:
|
||||
- ai-router-network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/api/providers"]
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "-O", "/dev/null", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
@@ -17,7 +17,7 @@ services:
|
||||
networks:
|
||||
- ai-router-network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/api/providers"]
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "-O", "/dev/null", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
Reference in New Issue
Block a user