mirror of
https://github.com/m1k1o/neko.git
synced 2025-07-19 17:49:31 +02:00
add healthcheck.
This commit is contained in:
parent
cd15e0b03e
commit
5a79212b32
3 changed files with 16 additions and 0 deletions
|
@ -110,6 +110,11 @@ ENV NEKO_SERVER_BIND=:8080
|
|||
# copy executabe from previous stage
|
||||
COPY --from=build /src/bin/neko /usr/bin/neko
|
||||
|
||||
#
|
||||
# add healthcheck
|
||||
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \
|
||||
CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/api/health || exit 1
|
||||
|
||||
#
|
||||
# run neko
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]
|
||||
|
|
|
@ -58,6 +58,11 @@ func (api *ApiManagerCtx) Route(r chi.Router) {
|
|||
r.Route(path, router)
|
||||
}
|
||||
})
|
||||
|
||||
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
//nolint
|
||||
w.Write([]byte("true"))
|
||||
})
|
||||
}
|
||||
|
||||
func (api *ApiManagerCtx) Authenticate(next http.Handler) http.Handler {
|
||||
|
|
|
@ -13,6 +13,12 @@ func Logger(next http.Handler) http.Handler {
|
|||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
req := map[string]interface{}{}
|
||||
|
||||
// exclude healthcheck from logs
|
||||
if r.RequestURI == "/api/health" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
if reqID := middleware.GetReqID(r.Context()); reqID != "" {
|
||||
req["id"] = reqID
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue