From 14fc3402c9e8681c90015c76dcdde89375d565a0 Mon Sep 17 00:00:00 2001 From: John Riebold Date: Mon, 21 Feb 2022 16:46:15 -0800 Subject: [PATCH] feat: Adds ability to override listen port --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 9eff2ec..8f5e2a8 100644 --- a/main.go +++ b/main.go @@ -137,13 +137,18 @@ func main() { } queueUrls := strings.Split(queueVar, ",") - log.Info().Int("interval", int(monitorInterval)).Strs("queueUrls", queueUrls).Msg("Starting queue monitors") + port, portSet := os.LookupEnv("PORT") + if !portSet || port == "" { + port = "8080" + } + + log.Info().Int("interval", int(monitorInterval)).Strs("queueUrls", queueUrls).Str("port", port).Msg("Starting queue monitors") go monitorQueues(queueUrls) http.Handle("/metrics", promhttp.Handler()) http.HandleFunc("/healthz", healthcheck) - err := http.ListenAndServe(":8080", nil) + err := http.ListenAndServe(":" + port, nil) if err != nil { log.Error().Str("errorMessage", err.Error()).Msg("Could not start http listener") os.Exit(1)