From 9766071815bf722c217ce2e9cc0cacbd9ed745cc Mon Sep 17 00:00:00 2001 From: all-hail-canada <59370393+all-hail-canada@users.noreply.github.com> Date: Tue, 31 Dec 2019 17:22:34 +0000 Subject: [PATCH] Display both server address and listening address in log (#300) * Show localhost in console output instead of 0.0.0.0 * Updated message to reflect both navigation and listening address Co-authored-by: InfiniteTF --- pkg/api/server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/api/server.go b/pkg/api/server.go index c7d0e98f5..b4a3851ea 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -200,6 +200,12 @@ func Start() { } }) + displayHost := config.GetHost() + if displayHost == "0.0.0.0" { + displayHost = "localhost" + } + displayAddress := displayHost + ":" + strconv.Itoa(config.GetPort()) + address := config.GetHost() + ":" + strconv.Itoa(config.GetPort()) if tlsConfig := makeTLSConfig(); tlsConfig != nil { httpsServer := &http.Server{ @@ -210,7 +216,8 @@ func Start() { go func() { printVersion() - logger.Infof("stash is running on HTTPS at https://" + address + "/") + logger.Infof("stash is listening on" + address) + logger.Infof("stash is running on HTTPS at https://" + displayAddress + "/") logger.Fatal(httpsServer.ListenAndServeTLS("", "")) }() } else { @@ -221,7 +228,8 @@ func Start() { go func() { printVersion() - logger.Infof("stash is running on HTTP at http://" + address + "/") + logger.Infof("stash is listening on" + address) + logger.Infof("stash is running on HTTP at http://" + displayAddress + "/") logger.Fatal(server.ListenAndServe()) }() }