Show error when ListenAndServe fails

and exit with 1
This commit is contained in:
Matt Baer 2018-11-10 20:41:35 -05:00
parent 59f436052e
commit ae019e4dc3
1 changed files with 5 additions and 1 deletions

6
app.go
View File

@ -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) {