From 7492095dd1cfed7f4b85a1ee801adfb43348ebf1 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Mon, 28 Dec 2020 02:39:08 +0100 Subject: [PATCH] configurable listen address --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d0cb9dc..1e51bfd 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,10 @@ func main() { if !ok { log.Fatalf("unable to read CONTAINER_NAME") } + listen, ok := os.LookupEnv("LISTEN") + if !ok { + listen = ":8080" + } defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"} cli, err := client.NewClient("unix:///var/run/docker.sock", "v1.44", nil, defaultHeaders) @@ -38,7 +42,7 @@ func main() { go counter.Scan(logs) http.HandleFunc("/", counter.MetricsHandler) - err = http.ListenAndServe(":8080", nil) + err = http.ListenAndServe(listen, nil) log.Fatalf("unable to listen: %s", err) }