diff --git a/main.go b/main.go index b590bf589..e77f861b5 100644 --- a/main.go +++ b/main.go @@ -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) {