Merge pull request #25 from OpenCHAMI/healthcheck

Add healthcheck for OpenCHAMI deployment recipes
This commit is contained in:
David Allen 2025-01-07 13:31:06 -07:00 committed by GitHub
commit 3253cb8bbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -125,6 +125,7 @@ func (s *Server) Serve() error {
} }
// always available public routes go here (none at the moment) // always available public routes go here (none at the moment)
router.HandleFunc("/configurator/status", s.GetStatus)
s.Handler = router s.Handler = router
return s.ListenAndServe() return s.ListenAndServe()
@ -225,6 +226,19 @@ func (s *Server) loadTargets() {
} }
} }
func (s *Server) GetStatus(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
data := map[string]any{
"code": 200,
"message": "Configurator is healthy",
}
err := json.NewEncoder(w).Encode(data)
if err != nil {
fmt.Printf("failed to encode JSON: %v\n", err)
return
}
}
// Create a new target with name, generator, templates, and files. // Create a new target with name, generator, templates, and files.
// //
// Example: // Example: