From ae019e4dc30ff3ced9d5a1b2950f514c1104c9ce Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 10 Nov 2018 20:41:35 -0500 Subject: [PATCH] Show error when ListenAndServe fails and exit with 1 --- app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index e9ff9b1..444d845 100644 --- a/app.go +++ b/app.go @@ -249,7 +249,11 @@ func Serve() { http.Handle("/", r) log.Info("Serving on http://localhost:%d\n", app.cfg.Server.Port) log.Info("---") - http.ListenAndServe(fmt.Sprintf(":%d", app.cfg.Server.Port), nil) + err = http.ListenAndServe(fmt.Sprintf(":%d", app.cfg.Server.Port), nil) + if err != nil { + log.Error("Unable to start: %v", err) + os.Exit(1) + } } func connectToDatabase(app *app) {