mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-03-29 20:39:54 +02:00
add healthz endpoint to server
This commit is contained in:
parent
acb6a8b02a
commit
bb8c569249
@ -169,6 +169,9 @@ func Load(mux *httptreemux.ContextMux, middleware ...gin.HandlerFunc) http.Handl
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.GET("/version", server.Version)
|
||||||
|
e.GET("/healthz", server.Health)
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
server/z.go
Normal file
24
server/z.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/drone/drone/store"
|
||||||
|
"github.com/drone/drone/version"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Health endpoint returns a 500 if the server state is unhealthy.
|
||||||
|
func Health(c *gin.Context) {
|
||||||
|
if err := store.FromContext(c).Ping(); err != nil {
|
||||||
|
c.String(500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.String(200, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version endpoint returns the server version and build information.
|
||||||
|
func Version(c *gin.Context) {
|
||||||
|
c.JSON(200, gin.H{
|
||||||
|
"source": "https://github.com/drone/drone",
|
||||||
|
"version": version.Version.String(),
|
||||||
|
})
|
||||||
|
}
|
@ -139,6 +139,8 @@ type Store interface {
|
|||||||
TaskList() ([]*model.Task, error)
|
TaskList() ([]*model.Task, error)
|
||||||
TaskInsert(*model.Task) error
|
TaskInsert(*model.Task) error
|
||||||
TaskDelete(string) error
|
TaskDelete(string) error
|
||||||
|
|
||||||
|
Ping() error
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUser gets a user by unique ID.
|
// GetUser gets a user by unique ID.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user