Split out cli arg handling from main

This commit is contained in:
Gabe Kangas 2021-10-24 23:09:30 -07:00
parent a40312d733
commit cd15661f08

31
main.go
View File

@ -23,10 +23,6 @@ func main() {
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
restoreDatabaseFile := flag.String("restoreDatabase", "", "Restore an Owncast database backup")
newStreamKey := flag.String("streamkey", "", "Set your stream key/admin password")
webServerPortOverride := flag.String("webserverport", "", "Force the web server to listen on a specific port")
webServerIPOverride := flag.String("webserverip", "", "Force web server to listen on this IP address")
rtmpPortOverride := flag.Int("rtmpport", 0, "Set listen port for the RTMP server")
flag.Parse()
@ -75,6 +71,24 @@ func main() {
log.Fatalln("failed to open database", err)
}
handleCommandLineFlags()
// starts the core
if err := core.Start(); err != nil {
log.Fatalln("failed to start the core package", err)
}
if err := router.Start(); err != nil {
log.Fatalln("failed to start/run the router", err)
}
}
func handleCommandLineFlags() {
newStreamKey := flag.String("streamkey", "", "Set your stream key/admin password")
webServerPortOverride := flag.String("webserverport", "", "Force the web server to listen on a specific port")
webServerIPOverride := flag.String("webserverip", "", "Force web server to listen on this IP address")
rtmpPortOverride := flag.Int("rtmpport", 0, "Set listen port for the RTMP server")
if *newStreamKey != "" {
if err := data.SetStreamKey(*newStreamKey); err != nil {
log.Errorln("Error setting your stream key.", err)
@ -115,15 +129,6 @@ func main() {
log.Errorln(err)
}
}
// starts the core
if err := core.Start(); err != nil {
log.Fatalln("failed to start the core package", err)
}
if err := router.Start(); err != nil {
log.Fatalln("failed to start/run the router", err)
}
}
func configureLogging(enableDebugFeatures bool, enableVerboseLogging bool) {