Skip to content

Commit 3253cb8

Browse files
authored
Merge pull request #25 from OpenCHAMI/healthcheck
Add healthcheck for OpenCHAMI deployment recipes
2 parents 7de2dcc + 6b0ed4c commit 3253cb8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/server/server.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (s *Server) Serve() error {
125125
}
126126

127127
// always available public routes go here (none at the moment)
128+
router.HandleFunc("/configurator/status", s.GetStatus)
128129

129130
s.Handler = router
130131
return s.ListenAndServe()
@@ -225,6 +226,19 @@ func (s *Server) loadTargets() {
225226
}
226227
}
227228

229+
func (s *Server) GetStatus(w http.ResponseWriter, r *http.Request) {
230+
w.Header().Set("Content-Type", "application/json")
231+
data := map[string]any{
232+
"code": 200,
233+
"message": "Configurator is healthy",
234+
}
235+
err := json.NewEncoder(w).Encode(data)
236+
if err != nil {
237+
fmt.Printf("failed to encode JSON: %v\n", err)
238+
return
239+
}
240+
}
241+
228242
// Create a new target with name, generator, templates, and files.
229243
//
230244
// Example:

0 commit comments

Comments
 (0)