From 46ac51c07f692c9f9ac8fc536cd9418d1a150dd7 Mon Sep 17 00:00:00 2001 From: Aliaksei Klimenka Date: Tue, 3 Nov 2020 18:36:50 +0300 Subject: [PATCH] * Fixed package name in Makefile + Added possibility to choose IP to listen --- Makefile | 2 +- README.md | 2 +- cmd/command.go | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bc5df8d..3fce569 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PACKAGE=github.com/rebuy-de/exporter-merger +PACKAGE=github.com/6RiverSystems/exporter-merger BIN=exporter-merger BUILD_VERSION=$(shell git describe --always --dirty --tags | tr '-' '.' ) BUILD_DATE=$(shell date) diff --git a/README.md b/README.md index 5aa7a66..4b41b0a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ exporters: To start the exporter: ``` -exporter-merger --config-path merger.yaml --listen-port 8080 +exporter-merger --config-path merger.yaml --listen-ip 10.100.1.2 --listen-port 8080 ``` ### Environment variables diff --git a/cmd/command.go b/cmd/command.go index 0d0daf5..d3f8839 100644 --- a/cmd/command.go +++ b/cmd/command.go @@ -64,6 +64,11 @@ func (app *App) Bind(cmd *cobra.Command) { "Listen port for the HTTP server. (ENV:MERGER_PORT)") app.viper.BindPFlag("port", cmd.PersistentFlags().Lookup("listen-port")) + cmd.PersistentFlags().String( + "listen-ip", "0.0.0.0", + "Listen IP for the HTTP server.(ENV:MERGER_IP)") + app.viper.BindPFlag("ip", cmd.PersistentFlags().Lookup("listen-ip")) + cmd.PersistentFlags().Int( "exporters-timeout", 10, "HTTP client timeout for connecting to exporters. (ENV:MERGER_EXPORTERSTIMEOUT)") @@ -83,8 +88,9 @@ func (app *App) run(cmd *cobra.Command, args []string) { }) port := app.viper.GetInt("port") - log.Infof("starting HTTP server on port %d", port) - err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil) + ip := app.viper.GetString("ip") + log.Infof("starting HTTP server on %s:%d", ip, port) + err := http.ListenAndServe(fmt.Sprintf("%s:%d", ip, port), nil) if err != nil { log.Fatal(err) }