From 5c228878fa88ca990d67005b16575bcdd9ebae43 Mon Sep 17 00:00:00 2001 From: zhoujunhao <18853925545@163.com> Date: Fri, 13 Jul 2018 12:20:16 +0800 Subject: [PATCH] [ADD] mq healthcheck api --- mq/api/api.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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"}) +}