feat: adds healtz

This commit is contained in:
Marvin Preuss 2024-09-23 10:33:13 +02:00
parent df89b1c7d1
commit aae4a94ffd
3 changed files with 9 additions and 3 deletions

View File

@ -6,7 +6,6 @@ tasks:
cmds:
- task: lint
- task: test
- task: docker-build
- task: docker-local-import
- task: test-integration
@ -15,7 +14,6 @@ tasks:
- task: lint
- task: test
- task: test-integration
- task: docker-build
- task: docker-publish
docker-build:
@ -24,6 +22,7 @@ tasks:
docker-local-import:
cmds:
- task: docker-build
- |
{{.NIX_CMD_BASE}} \
skopeo \
@ -44,6 +43,7 @@ tasks:
- GITHUB_PASSWORD
- GIT_TAG
cmds:
- task: docker-build
- |
{{.NIX_CMD_BASE}} \
skopeo \

View File

@ -28,6 +28,11 @@ func New(c config.Config) *Server {
s.logFiles = c.LogFiles
mux := http.NewServeMux()
mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte("ok")) //nolint:errcheck
})
mux.HandleFunc("/metrics", s.metrics)
s.httpServer = &http.Server{

View File

@ -98,7 +98,8 @@ func TestIntegration(t *testing.T) {
Mounts: vol,
Image: "caddy-log-exporter:latest",
ExposedPorts: []string{"2112:2112"},
WaitingFor: wait.ForLog("serving http"),
WaitingFor: wait.ForHTTP("http://127.0.0.1:2112/healthz").
WithStartupTimeout(5 * time.Minute),
},
},
)