From cde8251bd3a4e0e45aa4cf03ce918bbae08a2cdc Mon Sep 17 00:00:00 2001 From: Justin Li Date: Fri, 25 Jul 2014 03:43:06 -0400 Subject: [PATCH] Add logging for startup failure --- http/http.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/http/http.go b/http/http.go index 9fe894a..0aa764c 100644 --- a/http/http.go +++ b/http/http.go @@ -46,15 +46,15 @@ func makeHandler(handler ResponseHandler) httprouter.Handle { } if len(msg) > 0 || glog.V(2) { - reqString := r.URL.Path + reqString := r.URL.Path + " " + r.RemoteAddr if glog.V(3) { reqString = r.URL.RequestURI() + " " + r.RemoteAddr } if len(msg) > 0 { - glog.Errorf("[%d: %9s] %s (%s)", httpCode, duration, reqString, msg) + glog.Errorf("[%d - %9s] %s (%s)", httpCode, duration, reqString, msg) } else { - glog.Infof("[%d: %9s] %s", httpCode, duration, reqString) + glog.Infof("[%d - %9s] %s", httpCode, duration, reqString) } } @@ -127,10 +127,11 @@ func Serve(cfg *config.Config, tkr *tracker.Tracker) { }, } - grace.ListenAndServe() + if err := grace.ListenAndServe(); err != nil { + glog.Errorf("Failed to start server: %s", err.Error()) + } - err := srv.tracker.Close() - if err != nil { + if err := srv.tracker.Close(); err != nil { glog.Errorf("Failed to shutdown tracker cleanly: %s", err.Error()) } }