Merge pull request #25 from OpenCHAMI/healthcheck
Add healthcheck for OpenCHAMI deployment recipes
This commit is contained in:
commit
3253cb8bbb
1 changed files with 14 additions and 0 deletions
|
|
@ -125,6 +125,7 @@ func (s *Server) Serve() error {
|
|||
}
|
||||
|
||||
// always available public routes go here (none at the moment)
|
||||
router.HandleFunc("/configurator/status", s.GetStatus)
|
||||
|
||||
s.Handler = router
|
||||
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.
|
||||
//
|
||||
// Example:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue