File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ var defaultConf = ServerCfg{
6464 WriteTimeout : 10 ,
6565 ReadTimeout : 10 ,
6666 GopNum : 1 ,
67- Server : [] Application {{
67+ Server : Applications {{
6868 Appname : "live" ,
6969 Live : true ,
7070 Hls : true ,
@@ -81,13 +81,15 @@ func initLog() {
8181 }
8282}
8383
84- func LoadConfig () {
84+ func init () {
8585 defer Init ()
8686
8787 // Default config
8888 b , _ := json .Marshal (defaultConf )
8989 defaultConfig := bytes .NewReader (b )
90- Config .MergeConfig (defaultConfig )
90+ viper .SetConfigType ("json" )
91+ viper .ReadConfig (defaultConfig )
92+ Config .MergeConfigMap (viper .AllSettings ())
9193
9294 // Flags
9395 pflag .String ("rtmp_addr" , ":1935" , "RTMP server listen address" )
@@ -110,6 +112,8 @@ func LoadConfig() {
110112 if err != nil {
111113 log .Warning (err )
112114 log .Info ("Using default config" )
115+ } else {
116+ Config .MergeInConfig ()
113117 }
114118
115119 // Environment
@@ -121,6 +125,7 @@ func LoadConfig() {
121125 // Log
122126 initLog ()
123127
128+ // Print final config
124129 c := ServerCfg {}
125130 Config .Unmarshal (& c )
126131 log .Debugf ("Current configurations: \n %# v" , pretty .Formatter (c ))
Original file line number Diff line number Diff line change @@ -125,8 +125,6 @@ func main() {
125125 }
126126 }()
127127
128- configure .LoadConfig ()
129-
130128 log .Infof (`
131129 _ _ ____
132130 | | (_)_ _____ / ___| ___
You can’t perform that action at this time.
0 commit comments