summaryrefslogtreecommitdiff
path: root/registry-scanner/pkg/health/health.go
blob: cbc4977cd791d8e675191dedfd31f2bff38d44fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package health

// Most simple health check probe to see whether our server is still alive

import (
	"fmt"
	"net/http"

	"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
)

func StartHealthServer(port int) chan error {
	errCh := make(chan error)
	go func() {
		sm := http.NewServeMux()
		sm.HandleFunc("/healthz", HealthProbe)
		errCh <- http.ListenAndServe(fmt.Sprintf(":%d", port), sm)
	}()
	return errCh
}

func HealthProbe(w http.ResponseWriter, r *http.Request) {
	log.Tracef("/healthz ping request received, replying with pong")
	fmt.Fprintf(w, "OK\n")
}