Browse Source

Merge branch 'master' into webui

webui
Ruben Cid 5 years ago
parent
commit
ec6eb23c75
  1. 11
      configure/liveconfig.go
  2. 2
      main.go

11
configure/liveconfig.go

@ -65,7 +65,7 @@ var defaultConf = ServerCfg{ @@ -65,7 +65,7 @@ var defaultConf = ServerCfg{
WriteTimeout: 10,
ReadTimeout: 10,
GopNum: 1,
Server: []Application{{
Server: Applications{{
Appname: "live",
Live: true,
Hls: true,
@ -82,13 +82,15 @@ func initLog() { @@ -82,13 +82,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")
@ -112,6 +114,8 @@ func LoadConfig() { @@ -112,6 +114,8 @@ func LoadConfig() {
if err != nil {
log.Warning(err)
log.Info("Using default config")
} else {
Config.MergeInConfig()
}
// Environment
@ -123,6 +127,7 @@ func LoadConfig() { @@ -123,6 +127,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