Skip to content

Commit

Permalink
Make the Prometheus port configurable
Browse files Browse the repository at this point in the history
This enables people to run more than one worker (without containers) on one machine.

Resolves #3
  • Loading branch information
mulbc committed Apr 9, 2020
1 parent 3e6894a commit 473fb9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

var config common.WorkerConf
var prometheusPort int
var debug, trace bool

func init() {
Expand All @@ -28,6 +29,7 @@ func init() {
func main() {
var serverAddress string
flag.StringVar(&serverAddress, "s", "", "Gosbench Server IP and Port in the form '192.168.1.1:2000'")
flag.IntVar(&prometheusPort, "p", 8888, "Port on which the Prometheus Exporter will be available. Default: 8888")
flag.BoolVar(&debug, "d", false, "enable debug log output")
flag.BoolVar(&trace, "t", false, "enable trace log output")
flag.Parse()
Expand Down
4 changes: 3 additions & 1 deletion worker/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"io"
"net/http"

Expand Down Expand Up @@ -50,7 +51,8 @@ func init() {
mux := http.NewServeMux()
mux.Handle("/metrics", pe)
// http://localhost:8888/metrics
if err := http.ListenAndServe(":8888", mux); err != nil {
log.Infof("Starting Prometheus Exporter on port %d", prometheusPort)
if err := http.ListenAndServe(fmt.Sprintf(":%d", prometheusPort), mux); err != nil {
log.WithError(err).Fatalf("Failed to run Prometheus /metrics endpoint:")
}
}()
Expand Down

0 comments on commit 473fb9f

Please sign in to comment.