From 9b104f1d4021e00f4c18673bfa3c06d181d212d8 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 13 Jul 2020 14:48:56 -0700 Subject: [PATCH] Make setting the web server port optional --- config-example.yaml | 2 -- config/config.go | 9 +++++++++ router/router.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config-example.yaml b/config-example.yaml index a01af771a..b7c4508a9 100644 --- a/config-example.yaml +++ b/config-example.yaml @@ -1,5 +1,3 @@ -webServerPort: 8080 - instanceDetails: name: Owncast title: Owncast Demo Server diff --git a/config/config.go b/config/config.go index 665802052..56b23e972 100644 --- a/config/config.go +++ b/config/config.go @@ -180,6 +180,15 @@ func (c *config) GetPrivateHLSSavePath() string { return "hls" } +func (c *config) GetPublicWebServerPort() int { + if c.WebServerPort != 0 { + return c.WebServerPort + } + + // Default web server port + return 8080 +} + //Load tries to load the configuration file func Load(filePath string, versionInfo string) error { Config = new(config) diff --git a/router/router.go b/router/router.go index b310bf19c..9cdc6f4e2 100644 --- a/router/router.go +++ b/router/router.go @@ -34,7 +34,7 @@ func Start() error { http.HandleFunc("/config", controllers.GetWebConfig) } - port := config.Config.WebServerPort + port := config.Config.GetPublicWebServerPort() log.Infof("Web server running on port: %d", port)