511155e0a7
- Updated the CI configuration in .drone.yml to use the new Dockerfile located at ./cmd/web/Dockerfile. - Removed the old Dockerfile and Dockerfile-drone as they are no longer needed. - Refactored the cmd/web/Dockerfile to streamline the build process and improve organization. - Introduced a new bootstrap package to handle application initialization, including configuration, logging, MongoDB, Redis, and authorization service setup. - Added a health check endpoint for monitoring the server status, enhancing the API's operational capabilities.
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// @Summary Health check endpoint
|
|
// @Description Get comprehensive server health status including system information, dependencies status, and performance metrics. This endpoint is used for monitoring and load balancer health checks.
|
|
// @Tags Admin-Health
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} HealthResponse "System is healthy and operational"
|
|
// @Failure 503 {object} HealthResponse "System is unhealthy or experiencing issues"
|
|
// @Router /admin/v1/health [get]
|
|
func healthHandler(c echo.Context) error {
|
|
return c.JSON(http.StatusOK, HealthResponse{
|
|
Status: "healthy",
|
|
Time: time.Now().Unix(),
|
|
Version: "2.0.0",
|
|
Service: "tender-management-api",
|
|
Uptime: time.Since(time.Now()).String(),
|
|
})
|
|
}
|
|
|
|
// HealthResponse represents the comprehensive health check response
|
|
type HealthResponse struct {
|
|
Status string `json:"status" example:"healthy"` // Current health status
|
|
Time int64 `json:"time" example:"1699123456"` // Current Unix timestamp
|
|
Version string `json:"version" example:"2.0.0"` // API version
|
|
Service string `json:"service" example:"tender-management-api"` // Service name
|
|
Uptime string `json:"uptime,omitempty" example:"24h30m15s"` // Service uptime duration
|
|
}
|