Add startup banner

This commit is contained in:
Deluan
2020-01-13 18:24:42 -05:00
parent 0673371a71
commit c995766c45
3 changed files with 23 additions and 5 deletions
-4
View File
@@ -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)
+4 -1
View File
@@ -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))
}
+19
View File
@@ -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)
}