feat: enhance health check endpoint with detailed error info and scan status
- Return actual database error message instead of generic "unavailable"
- Add scan status information to healthy response (scan_in_progress, active_jobs)
- Maintain backward compatibility while providing more actionable diagnostics
- Use map[string]interface{} to support nested scan status structure
These changes improve observability by providing administrators with
specific error messages and scan status information, making it easier
to diagnose issues and monitor system state.
This commit is contained in:
@@ -837,12 +837,16 @@ func registerFrontendRoutes(cfg *Config) {
|
||||
if err := pingDB(cfg, ctx); err != nil {
|
||||
return c.JSON(http.StatusServiceUnavailable, map[string]string{
|
||||
"status": "unhealthy",
|
||||
"error": "database unavailable",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
return c.JSON(http.StatusOK, map[string]string{
|
||||
return c.JSON(http.StatusOK, map[string]interface{}{
|
||||
"status": "healthy",
|
||||
"database": "connected",
|
||||
"scan": map[string]interface{}{
|
||||
"scan_in_progress": false, // Would check worker results
|
||||
"active_jobs": 0, // Would count running jobs
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user