Skip to content

Commit

Permalink
Default config fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GNURub committed Apr 15, 2020
1 parent 480ac49 commit 3a0337e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions configure/liveconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var defaultConf = ServerCfg{
WriteTimeout: 10,
ReadTimeout: 10,
GopNum: 1,
Server: []Application{{
Server: Applications{{
Appname: "live",
Live: true,
Hls: true,
Expand All @@ -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")
Expand All @@ -110,6 +112,8 @@ func LoadConfig() {
if err != nil {
log.Warning(err)
log.Info("Using default config")
} else {
Config.MergeInConfig()
}

// Environment
Expand All @@ -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))
Expand Down

0 comments on commit 3a0337e

Please sign in to comment.