From c995766c45bbf58f147a12e025cea53947fd6d33 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 13 Jan 2020 18:24:42 -0500 Subject: [PATCH] Add startup banner --- main.go | 4 ---- server/app.go | 5 ++++- server/banner.go | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 server/banner.go diff --git a/main.go b/main.go index 928a9bee4..556372e17 100644 --- a/main.go +++ b/main.go @@ -1,16 +1,12 @@ package main import ( - "fmt" - "github.com/cloudsonic/sonic-server/conf" ) func main() { conf.Load() - fmt.Printf("\nCloudSonic Server v%s\n\n", "0.2") - a := CreateApp(conf.Sonic.MusicFolder) a.MountRouter("/rest/", CreateSubsonicAPIRouter()) a.Run(":" + conf.Sonic.Port) diff --git a/server/app.go b/server/app.go index 565850eae..632d00fbc 100644 --- a/server/app.go +++ b/server/app.go @@ -14,6 +14,8 @@ import ( "github.com/go-chi/cors" ) +const Version = "0.2" + type Server struct { Importer *scanner.Importer router *chi.Mux @@ -21,6 +23,7 @@ type Server struct { func New(importer *scanner.Importer) *Server { a := &Server{Importer: importer} + showBanner(Version) initMimeTypes() a.initRoutes() a.initImporter() @@ -35,7 +38,7 @@ func (a *Server) MountRouter(path string, subRouter http.Handler) { } func (a *Server) Run(addr string) { - log.Info("Started CloudSonic server", "address", addr) + log.Info("Starting CloudSonic server", "address", addr) log.Error(http.ListenAndServe(addr, a.router)) } diff --git a/server/banner.go b/server/banner.go new file mode 100644 index 000000000..9cda90eb1 --- /dev/null +++ b/server/banner.go @@ -0,0 +1,19 @@ +package server + +import "fmt" + +// http://patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=Cloud%20Sonic +const banner = ` + ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ███████╗ ██████╗ ███╗ ██╗██╗ ██████╗ +██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗ ██╔════╝██╔═══██╗████╗ ██║██║██╔════╝ +██║ ██║ ██║ ██║██║ ██║██║ ██║ ███████╗██║ ██║██╔██╗ ██║██║██║ +██║ ██║ ██║ ██║██║ ██║██║ ██║ ╚════██║██║ ██║██║╚██╗██║██║██║ +╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝ ███████║╚██████╔╝██║ ╚████║██║╚██████╗ + ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═════╝ +Version %s + +` + +func showBanner(version string) { + fmt.Printf(banner, version) +}