From b27d528d6975eb7f89f52104cf246ecf041cc1f4 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Mon, 27 Aug 2018 21:07:23 +0100 Subject: [PATCH] Allow disabling debug server --- grpc.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/grpc.go b/grpc.go index ddc978fe..a47877ee 100644 --- a/grpc.go +++ b/grpc.go @@ -123,21 +123,25 @@ func (s *server) serveForever() { }() glog.Infof("Listening for GRPC on %v", s.opts.listenAddress) - httpMux := http.NewServeMux() - httpMux.HandleFunc("/debug/status", statusz.StatusHandler) - httpMux.HandleFunc("/debug/requests", trace.Traces) - httpMux.HandleFunc("/", statusz.StatusHandler) + if s.opts.debugAddress == "" { + glog.Info("Disabling debug HTTP server") + } else { + httpMux := http.NewServeMux() + httpMux.HandleFunc("/debug/status", statusz.StatusHandler) + httpMux.HandleFunc("/debug/requests", trace.Traces) + httpMux.HandleFunc("/", statusz.StatusHandler) - if err := s.setupDebugHTTP(httpMux); err != nil { - glog.Exitf("Could not setup HTTP server: %v", err) - } - - go func() { - if err := s.http.server.Serve(s.http.listen); err != nil { - glog.Exitf("Could not start HTTP server: %v", err) + if err := s.setupDebugHTTP(httpMux); err != nil { + glog.Exitf("Could not setup HTTP server: %v", err) } - }() - glog.Infof("Listening for HTTP on %v", s.opts.debugAddress) + + go func() { + if err := s.http.server.Serve(s.http.listen); err != nil { + glog.Exitf("Could not start HTTP server: %v", err) + } + }() + glog.Infof("Listening for HTTP on %v", s.opts.debugAddress) + } select {} }