Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Small improvements in the server part #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand All @@ -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)
}
Expand Down