Fix startup order, setting LogLevel
This commit is contained in:
@@ -41,7 +41,10 @@ func LoadFromEnv() {
|
|||||||
Sonic.Port = port
|
Sonic.Port = port
|
||||||
}
|
}
|
||||||
l := &multiconfig.EnvironmentLoader{}
|
l := &multiconfig.EnvironmentLoader{}
|
||||||
l.Load(Sonic)
|
err := l.Load(Sonic)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error parsing configuration from environment")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadFromTags() {
|
func LoadFromTags() {
|
||||||
@@ -55,7 +58,6 @@ func LoadFromFile(tomlFile string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error loading configuration file", "file", tomlFile, err)
|
log.Error("Error loading configuration file", "file", tomlFile, err)
|
||||||
}
|
}
|
||||||
log.SetLogLevelString(Sonic.LogLevel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadFromLocalFile() {
|
func LoadFromLocalFile() {
|
||||||
@@ -68,6 +70,7 @@ func Load() {
|
|||||||
LoadFromLocalFile()
|
LoadFromLocalFile()
|
||||||
LoadFromEnv()
|
LoadFromEnv()
|
||||||
LoadFromFlags()
|
LoadFromFlags()
|
||||||
|
log.SetLogLevelString(Sonic.LogLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cloudsonic/sonic-server/conf"
|
"github.com/cloudsonic/sonic-server/conf"
|
||||||
|
"github.com/cloudsonic/sonic-server/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
conf.Load()
|
conf.Load()
|
||||||
|
|
||||||
|
if !conf.Sonic.DevDisableBanner {
|
||||||
|
server.ShowBanner()
|
||||||
|
}
|
||||||
|
|
||||||
a := CreateServer(conf.Sonic.MusicFolder)
|
a := CreateServer(conf.Sonic.MusicFolder)
|
||||||
a.MountRouter("/rest", CreateSubsonicAPIRouter())
|
a.MountRouter("/rest", CreateSubsonicAPIRouter())
|
||||||
a.MountRouter("/app", CreateAppRouter("/app"))
|
a.MountRouter("/app", CreateAppRouter("/app"))
|
||||||
|
|||||||
+2
-2
@@ -14,6 +14,6 @@ Version %s
|
|||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
func showBanner(version string) {
|
func ShowBanner() {
|
||||||
fmt.Printf(banner, version)
|
fmt.Printf(banner, Version)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ type Server struct {
|
|||||||
|
|
||||||
func New(scanner *scanner.Scanner, ds model.DataStore) *Server {
|
func New(scanner *scanner.Scanner, ds model.DataStore) *Server {
|
||||||
a := &Server{Scanner: scanner, ds: ds}
|
a := &Server{Scanner: scanner, ds: ds}
|
||||||
if !conf.Sonic.DevDisableBanner {
|
|
||||||
showBanner(Version)
|
|
||||||
}
|
|
||||||
initMimeTypes()
|
initMimeTypes()
|
||||||
initialSetup(ds)
|
initialSetup(ds)
|
||||||
a.initRoutes()
|
a.initRoutes()
|
||||||
|
|||||||
Reference in New Issue
Block a user