From 4a6ab368c65501bdb04098b64e5ea0ac8117ec02 Mon Sep 17 00:00:00 2001 From: Tyler Date: Sun, 14 Jun 2020 05:48:56 -0400 Subject: [PATCH] Better starting message --- server.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index c2c8c8b..2ce3b4f 100644 --- a/server.go +++ b/server.go @@ -22,7 +22,7 @@ import ( "sync" ) -var VERSION = "1.4.1" +var VERSION = "1.4.4" func packageName(name string) string { if index := strings.Index(name, "_"); index != -1 { @@ -60,6 +60,11 @@ func main() { os.Exit(0) } + log.WithFields(log.Fields{ + "version": VERSION, + "runtimeVersion": runtime.Version(), + }).Info("Starting deb-simple") + file, err := ioutil.ReadFile(*configFile) if err != nil { @@ -148,11 +153,21 @@ func main() { bind := fmt.Sprintf(":%d", conf.Http.Port) if conf.Http.SSL { - log.Info("running with SSL enabled") - log.Fatalln(http.ListenAndServeTLS(bind, conf.Http.SSLCert, conf.Http.SSLKey, mux)) + log.WithFields(log.Fields{ + "bind": bind, + "certFile": conf.Http.SSLCert, + "keyFile": conf.Http.SSLKey, + }).Info("Starting with SSL enabled") + + err = http.ListenAndServeTLS(bind, conf.Http.SSLCert, conf.Http.SSLKey, mux) } else { - log.Info("running without SSL enabled") - log.Fatalln(http.ListenAndServe(bind, mux)) + log.WithField("bind", bind).Info("Starting without SSL enabled") + + err = http.ListenAndServe(bind, mux) + } + + if err != nil { + log.WithError(err).Fatalln("Unable to start or keep running due to error") } }