From a60c2f2d2f1f129c4c4350a612ed404b864406c6 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Tue, 20 Feb 2018 17:41:56 +0100 Subject: [PATCH] Add some logging & version info building --- app.go | 18 +++++++++++++++++- runner/runner.go | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index ef5c081..fa4d09d 100644 --- a/app.go +++ b/app.go @@ -4,14 +4,30 @@ import ( "math/rand" "time" + "fmt" + "github.com/gin-gonic/gin" "github.com/gotify/server/config" "github.com/gotify/server/database" + "github.com/gotify/server/model" "github.com/gotify/server/router" "github.com/gotify/server/runner" ) +var ( + // Version the version of Gotify. + Version = "unknown" + // Commit the git commit hash of this version. + Commit = "unknown" + // BuildDate the date on which this binary was build. + BuildDate = "unknown" + // Branch the git branch of this version. + Branch = "unknown" + vInfo = &model.VersionInfo{Version: Version, Commit: Commit, BuildDate: BuildDate, Branch: Branch} +) + func main() { + fmt.Println("Starting Gotify version", Version+"@"+BuildDate) rand.Seed(time.Now().UnixNano()) conf := config.Get() db, err := database.New(conf.Database.Dialect, conf.Database.Connection, conf.DefaultUser.Name, conf.DefaultUser.Pass) @@ -21,7 +37,7 @@ func main() { defer db.Close() gin.SetMode(gin.ReleaseMode) - engine, closeable := router.Create(db) + engine, closeable := router.Create(db, vInfo) defer closeable() runner.Run(engine, conf) diff --git a/runner/runner.go b/runner/runner.go index 60d50b5..22df428 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -37,8 +37,10 @@ func Run(engine *gin.Engine, conf *config.Configuration) { httpHandler = certManager.HTTPHandler(httpHandler) s.TLSConfig = &tls.Config{GetCertificate: certManager.GetCertificate} } + fmt.Println("Started Listening on port", conf.Server.SSL.Port) go log.Fatal(s.ListenAndServeTLS(conf.Server.SSL.CertFile, conf.Server.SSL.CertKey)) } + fmt.Println("Started Listening on port", conf.Server.Port) log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", conf.Server.Port), httpHandler)) }