mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-10 06:14:22 +00:00
add ready and healthy probe endpoints
This commit is contained in:
committed by
Benj Fassbind
parent
352f4e8772
commit
2020ca9971
+8
-5
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sync/atomic"
|
||||
|
||||
ctx "github.com/aptly-dev/aptly/context"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -25,11 +26,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
router.Use(gin.ErrorLogger())
|
||||
|
||||
if c.Config().EnableMetricsEndpoint {
|
||||
router.Use(instrumentHandlerInFlight(apiRequestsInFlightGauge, getBasePath))
|
||||
router.Use(instrumentHandlerCounter(apiRequestsTotalCounter, getBasePath))
|
||||
router.Use(instrumentHandlerRequestSize(apiRequestSizeSummary, getBasePath))
|
||||
router.Use(instrumentHandlerResponseSize(apiResponseSizeSummary, getBasePath))
|
||||
router.Use(instrumentHandlerDuration(apiRequestsDurationSummary, getBasePath))
|
||||
MetricsCollectorRegistrar.Register(router)
|
||||
}
|
||||
|
||||
if context.Flags().Lookup("no-lock").Value.Get().(bool) {
|
||||
@@ -71,6 +68,12 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
||||
root.GET("/metrics", apiMetricsGet())
|
||||
}
|
||||
root.GET("/version", apiVersion)
|
||||
|
||||
isReady := &atomic.Value{}
|
||||
isReady.Store(false)
|
||||
defer isReady.Store(true)
|
||||
root.GET("/ready", apiReady(isReady))
|
||||
root.GET("/healthy", apiHealthy)
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user