Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
吴浩麟 committed Apr 25, 2020
2 parents 782be18 + bd7debe commit 497c431
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 8 additions & 3 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 @@ -81,13 +81,15 @@ func initLog() {
}
}

func LoadConfig() {
func init() {
defer Init()

// 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
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func main() {
}
}()

configure.LoadConfig()

log.Infof(`
_ _ ____
| | (_)_ _____ / ___| ___
Expand Down

0 comments on commit 497c431

Please sign in to comment.