feat: add health check handler
parent
d2e6d23741
commit
a721dc1f31
|
@ -1,2 +1,3 @@
|
||||||
*
|
*
|
||||||
|
!.docker.json
|
||||||
!filebrowser
|
!filebrowser
|
|
@ -1,6 +1,10 @@
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
RUN apk --update add ca-certificates
|
RUN apk --update add ca-certificates \
|
||||||
RUN apk --update add mailcap
|
mailcap \
|
||||||
|
curl
|
||||||
|
|
||||||
|
HEALTHCHECK --start-period=2s --interval=5s --timeout=3s \
|
||||||
|
CMD curl -f http://localhost/health || exit 1
|
||||||
|
|
||||||
VOLUME /srv
|
VOLUME /srv
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
|
@ -36,6 +36,7 @@ func NewHandler(
|
||||||
return handle(fn, prefix, store, server)
|
return handle(fn, prefix, store, server)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.HandleFunc("/health", healthHandler)
|
||||||
r.PathPrefix("/static").Handler(static)
|
r.PathPrefix("/static").Handler(static)
|
||||||
r.NotFoundHandler = index
|
r.NotFoundHandler = index
|
||||||
|
|
||||||
|
|
|
@ -136,3 +136,8 @@ func authenticateShareRequest(r *http.Request, l *share.Link) (int, error) {
|
||||||
|
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func healthHandler(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
_, _ = w.Write([]byte(`{"status":"OK"}`))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue