From 3a0337eb8b673fee3983daac55a1075a51a92f29 Mon Sep 17 00:00:00 2001 From: Ruben Cid Date: Wed, 15 Apr 2020 13:37:50 +0200 Subject: [PATCH 1/2] Default config fix --- configure/liveconfig.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/configure/liveconfig.go b/configure/liveconfig.go index 9df3143f..cc71490c 100644 --- a/configure/liveconfig.go +++ b/configure/liveconfig.go @@ -64,7 +64,7 @@ var defaultConf = ServerCfg{ WriteTimeout: 10, ReadTimeout: 10, GopNum: 1, - Server: []Application{{ + Server: Applications{{ Appname: "live", Live: true, Hls: true, @@ -87,7 +87,9 @@ func LoadConfig() { // Default config b, _ := json.Marshal(defaultConf) defaultConfig := bytes.NewReader(b) - Config.MergeConfig(defaultConfig) + viper.SetConfigType("json") + viper.ReadConfig(defaultConfig) + Config.MergeConfigMap(viper.AllSettings()) // Flags pflag.String("rtmp_addr", ":1935", "RTMP server listen address") @@ -110,6 +112,8 @@ func LoadConfig() { if err != nil { log.Warning(err) log.Info("Using default config") + } else { + Config.MergeInConfig() } // Environment @@ -121,6 +125,7 @@ func LoadConfig() { // Log initLog() + // Print final config c := ServerCfg{} Config.Unmarshal(&c) log.Debugf("Current configurations: \n%# v", pretty.Formatter(c)) From 22714df888741f440bb67d54c79d4a7173d6d2e0 Mon Sep 17 00:00:00 2001 From: Ruben Cid Date: Wed, 15 Apr 2020 13:51:02 +0200 Subject: [PATCH 2/2] Fix config default --- configure/liveconfig.go | 2 +- main.go | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/configure/liveconfig.go b/configure/liveconfig.go index cc71490c..4018d858 100644 --- a/configure/liveconfig.go +++ b/configure/liveconfig.go @@ -81,7 +81,7 @@ func initLog() { } } -func LoadConfig() { +func init() { defer Init() // Default config diff --git a/main.go b/main.go index e3a7cb22..32a9f2d7 100755 --- a/main.go +++ b/main.go @@ -125,8 +125,6 @@ func main() { } }() - configure.LoadConfig() - log.Infof(` _ _ ____ | | (_)_ _____ / ___| ___