diff --git a/mq/api/api.go b/mq/api/api.go index 173b2d428..34e204bae 100644 --- a/mq/api/api.go +++ b/mq/api/api.go @@ -43,6 +43,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/version" + httputil "github.com/goodrain/rainbond/util/http" ) type Manager struct { @@ -105,6 +106,7 @@ func NewManager(c option.Config) (*Manager, error) { } go func() { Prometheus() + health() if err := http.ListenAndServe(":6301", nil); err != nil { logrus.Error("mq pprof listen error.", err.Error()) } @@ -185,3 +187,11 @@ func Prometheus() { prometheus.MustRegister(exporter) http.Handle("/metrics", promhttp.Handler()) } + +func health() { + http.HandleFunc("/health", checkHalth) +} + +func checkHalth(w http.ResponseWriter, r *http.Request) { + httputil.ReturnSuccess(r, w, map[string]string{"status": "health", "info": "mq service health"}) +}