Browse Source

Merge pull request #91 from GNURub/fix_default_config

Fix default config
webui 0.0.10
浩麟 6 years ago committed by GitHub
parent
commit
bd7debee3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      configure/liveconfig.go
  2. 2
      main.go

11
configure/liveconfig.go

@ -64,7 +64,7 @@ var defaultConf = ServerCfg{ @@ -64,7 +64,7 @@ var defaultConf = ServerCfg{
WriteTimeout: 10,
ReadTimeout: 10,
GopNum: 1,
Server: []Application{{
Server: Applications{{
Appname: "live",
Live: true,
Hls: true,
@ -81,13 +81,15 @@ func initLog() { @@ -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")
@ -110,6 +112,8 @@ func LoadConfig() { @@ -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() { @@ -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))

2
main.go

@ -125,8 +125,6 @@ func main() { @@ -125,8 +125,6 @@ func main() {
}
}()
configure.LoadConfig()
log.Infof(`
_ _ ____
| | (_)_ _____ / ___| ___

Loading…
Cancel
Save