summaryrefslogtreecommitdiff
path: root/pkg/health/health.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/health/health.go')
-rw-r--r--pkg/health/health.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/health/health.go b/pkg/health/health.go
new file mode 100644
index 0000000..cbc4977
--- /dev/null
+++ b/pkg/health/health.go
@@ -0,0 +1,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")
+}