Skip to content

Commit

Permalink
fix: support run without config file
Browse files Browse the repository at this point in the history
close #74
  • Loading branch information
吴浩麟 committed Apr 10, 2020
1 parent 3da66e7 commit 5219d1c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
18 changes: 10 additions & 8 deletions configure/liveconfig.go
Expand Up @@ -45,28 +45,30 @@ type ServerCfg struct {
Server []Application `json:"server"`
}

var RtmpServercfg ServerCfg
// default config
var RtmpServercfg = ServerCfg{
Server: []Application{{
Appname: "livego",
Liveon: "on",
Hlson: "on",
StaticPush: nil,
}},
}

func LoadConfig(configfilename string) error {
func LoadConfig(configfilename string) {
log.Printf("starting load configure file %s", configfilename)
data, err := ioutil.ReadFile(configfilename)
if err != nil {
log.Printf("ReadFile %s error:%v", configfilename, err)
return err
}

// log.Printf("loadconfig: \r\n%s", string(data))

err = json.Unmarshal(data, &RtmpServercfg)
if err != nil {
log.Printf("json.Unmarshal error:%v", err)
return err
}
log.Printf("get config json data:%v", RtmpServercfg)

Init()

return nil
}

func GetKeyFile() *string {
Expand Down
2 changes: 1 addition & 1 deletion config/livego.json → livego.json
@@ -1,7 +1,7 @@
{
"server": [
{
"appname": "live",
"appname": "livego",
"liveon": "on",
"hlson": "on"
}
Expand Down
7 changes: 2 additions & 5 deletions main.go
Expand Up @@ -19,7 +19,7 @@ var (
httpFlvAddr = flag.String("httpflv-addr", ":7001", "HTTP-FLV server listen address")
hlsAddr = flag.String("hls-addr", ":7002", "HLS server listen address")
operaAddr = flag.String("manage-addr", ":8090", "HTTP manage interface server listen address")
configfilename = flag.String("config-file", "config/livego.json", "configure filename")
configfilename = flag.String("config-file", "livego.json", "configure filename")
)

func init() {
Expand Down Expand Up @@ -116,10 +116,7 @@ func main() {
}
}()
log.Println("start livego, version", version)
err := configure.LoadConfig(*configfilename)
if err != nil {
return
}
configure.LoadConfig(*configfilename)

stream := rtmp.NewRtmpStream()
hlsServer := startHls()
Expand Down

0 comments on commit 5219d1c

Please sign in to comment.