diff --git a/.gitignore b/.gitignore index 4e0b108..983b029 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ __pycache__/ .idea .ipynb_checkpoints */.ipynb_checkpoints/* +go.mod +go.sum +go/src/ltfs-vof/go.mod +go/src/ltfs-vof/go.sum diff --git a/go/src/ltfs-vof/main.go b/go/src/ltfs-vof/main.go index 60ca310..672a1a2 100644 --- a/go/src/ltfs-vof/main.go +++ b/go/src/ltfs-vof/main.go @@ -8,6 +8,7 @@ import ( "io/ioutil" . "ltfs-vof/tapehardware" . "ltfs-vof/utils" + "net/http" "strings" ) @@ -47,8 +48,12 @@ func main() { simPacks := flag.Bool("simpacks", false, "Put Pack List Into Database") var simBuckets stringSlice flag.Var(&simBuckets, "simbucket", "simbucket may be repeated to create multiple simulation buckets") + healthPort := flag.String("healthport", "8080", "Port for health check endpoint") flag.Parse() + // Start health check server in background + go startHealthCheckServer(*healthPort) + // create the customer logger logger := NewLogger(*logFile, *clean) @@ -165,3 +170,23 @@ func (s *stringSlice) Set(value string) error { func (s *stringSlice) Slice() []string { return []string(*s) } + +// startHealthCheckServer starts an HTTP server for health checks +// This is used by MinIO Sidekick for load balancer health monitoring +func startHealthCheckServer(port string) { + http.HandleFunc("/health", healthCheckHandler) + http.HandleFunc("/healthz", healthCheckHandler) + http.HandleFunc("/", healthCheckHandler) + + addr := ":" + port + fmt.Printf("Starting health check server on %s\n", addr) + if err := http.ListenAndServe(addr, nil); err != nil { + fmt.Printf("Health check server error: %v\n", err) + } +} + +// healthCheckHandler responds with 200 OK for health checks +func healthCheckHandler(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte("OK")) +}