|
|
@ -65,7 +65,7 @@ var defaultConf = ServerCfg{ |
|
|
|
WriteTimeout: 10, |
|
|
|
WriteTimeout: 10, |
|
|
|
ReadTimeout: 10, |
|
|
|
ReadTimeout: 10, |
|
|
|
GopNum: 1, |
|
|
|
GopNum: 1, |
|
|
|
Server: []Application{{ |
|
|
|
Server: Applications{{ |
|
|
|
Appname: "live", |
|
|
|
Appname: "live", |
|
|
|
Live: true, |
|
|
|
Live: true, |
|
|
|
Hls: true, |
|
|
|
Hls: true, |
|
|
@ -82,13 +82,15 @@ func initLog() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func LoadConfig() { |
|
|
|
func init() { |
|
|
|
defer Init() |
|
|
|
defer Init() |
|
|
|
|
|
|
|
|
|
|
|
// Default config
|
|
|
|
// Default config
|
|
|
|
b, _ := json.Marshal(defaultConf) |
|
|
|
b, _ := json.Marshal(defaultConf) |
|
|
|
defaultConfig := bytes.NewReader(b) |
|
|
|
defaultConfig := bytes.NewReader(b) |
|
|
|
Config.MergeConfig(defaultConfig) |
|
|
|
viper.SetConfigType("json") |
|
|
|
|
|
|
|
viper.ReadConfig(defaultConfig) |
|
|
|
|
|
|
|
Config.MergeConfigMap(viper.AllSettings()) |
|
|
|
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
// Flags
|
|
|
|
pflag.String("rtmp_addr", ":1935", "RTMP server listen address") |
|
|
|
pflag.String("rtmp_addr", ":1935", "RTMP server listen address") |
|
|
@ -112,6 +114,8 @@ func LoadConfig() { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Warning(err) |
|
|
|
log.Warning(err) |
|
|
|
log.Info("Using default config") |
|
|
|
log.Info("Using default config") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Config.MergeInConfig() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Environment
|
|
|
|
// Environment
|
|
|
@ -123,6 +127,7 @@ func LoadConfig() { |
|
|
|
// Log
|
|
|
|
// Log
|
|
|
|
initLog() |
|
|
|
initLog() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Print final config
|
|
|
|
c := ServerCfg{} |
|
|
|
c := ServerCfg{} |
|
|
|
Config.Unmarshal(&c) |
|
|
|
Config.Unmarshal(&c) |
|
|
|
log.Debugf("Current configurations: \n%# v", pretty.Formatter(c)) |
|
|
|
log.Debugf("Current configurations: \n%# v", pretty.Formatter(c)) |
|
|
|