log and health check
This commit is contained in:
parent
97079fd3fa
commit
43568aeb36
2 changed files with 23 additions and 2 deletions
|
|
@ -22,8 +22,29 @@ func main() {
|
||||||
u = NewUpdater()
|
u = NewUpdater()
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
e.Use(middleware.RequestLogger())
|
skipper := func(c *echo.Context) bool {
|
||||||
|
// Skip health check endpoint
|
||||||
|
return c.Request().URL.Path == "/health"
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
|
||||||
|
LogStatus: true,
|
||||||
|
LogURI: true,
|
||||||
|
LogMethod: true,
|
||||||
|
Skipper: skipper,
|
||||||
|
HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
|
||||||
|
LogValuesFunc: func(c *echo.Context, v middleware.RequestLoggerValues) error {
|
||||||
|
var errMsg string
|
||||||
|
if v.Error != nil {
|
||||||
|
errMsg = fmt.Sprintf(" ERROR: %s", v.Error.Error())
|
||||||
|
}
|
||||||
|
fmt.Printf("[%s %s]: %d%s\n", v.Method, v.URI, v.Status, errMsg)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
e.GET("/", func(c *echo.Context) error {
|
||||||
|
return c.String(http.StatusOK, "OK")
|
||||||
|
})
|
||||||
e.GET("/test", func(c *echo.Context) error {
|
e.GET("/test", func(c *echo.Context) error {
|
||||||
|
|
||||||
return c.JSONPretty(http.StatusOK,
|
return c.JSONPretty(http.StatusOK,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ services:
|
||||||
IMAGEOPTION: "true"
|
IMAGEOPTION: "true"
|
||||||
CONCURRENT_IMAGES: ${CONCURRENT_IMAGES}
|
CONCURRENT_IMAGES: ${CONCURRENT_IMAGES}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:1323/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:1323"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue