diff --git a/bailongma/blm_prometheus/server.go b/bailongma/blm_prometheus/server.go index ba48cec65bfccdd3c1bcf9c2838a01fa96b8c43e..a2aafd578e01653613dc445f3ca0b47528917379 100644 --- a/bailongma/blm_prometheus/server.go +++ b/bailongma/blm_prometheus/server.go @@ -184,6 +184,7 @@ func main() { } http.HandleFunc("/receive", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusAccepted) addr := strings.Split(r.RemoteAddr, ":") idx := TAOShashID([]byte(addr[0])) @@ -192,7 +193,7 @@ func main() { http.Error(w, err.Error(), http.StatusInternalServerError) return } - + r.Body.Close() reqBuf, err := snappy.Decode(nil, compressed) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) @@ -205,7 +206,7 @@ func main() { return } nodeChans[idx%httpworkers] <- req - w.WriteHeader(http.StatusAccepted) + }) http.HandleFunc("/check", func(w http.ResponseWriter, r *http.Request) { diff --git a/bailongma/blm_telegraf/server.go b/bailongma/blm_telegraf/server.go index e5957cfc8e4f1f72e3e9534fc238696c71202506..17799f23187ac8462e865177a89b71c116b415e5 100644 --- a/bailongma/blm_telegraf/server.go +++ b/bailongma/blm_telegraf/server.go @@ -149,6 +149,7 @@ func main() { } http.HandleFunc("/telegraf", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusAccepted) addr := strings.Split(r.RemoteAddr, ":") idx := TAOShashID([]byte(addr[0])) @@ -157,7 +158,7 @@ func main() { http.Error(w, err.Error(), http.StatusInternalServerError) return } - + r.Body.Close() var req Metrics if err := json.Unmarshal(reqBuf, &req); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) @@ -166,7 +167,7 @@ func main() { req.HostIP = addr[0] nodeChans[idx%httpworkers] <- req - w.WriteHeader(http.StatusAccepted) + //w.WriteHeader(http.StatusAccepted) }) http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent)