Skip to content

Commit aa865b8

Browse files
committed
Configure metrics port as a flag
1 parent 9fc5637 commit aa865b8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package cmd
2323
import (
2424
"bytes"
2525
"encoding/json"
26+
"fmt"
2627
"io/ioutil"
2728
"log"
2829
"net/http"
@@ -59,6 +60,7 @@ var sqsEndpoint string
5960
var parallelRequests int
6061
var svc *sqs.SQS
6162
var httpClient *http.Client
63+
var port int
6264

6365
// RootCmd represents the base command when called without any subcommands
6466
var RootCmd = &cobra.Command{
@@ -86,6 +88,7 @@ func init() {
8688
RootCmd.PersistentFlags().StringVar(&awsRegion, "aws-region", "us-east-1", "AWS Region for the SQS queue")
8789
RootCmd.PersistentFlags().StringVar(&sqsEndpoint, "sqs-endpoint", "", "SQS Endpoint for using with fake_sqs")
8890
RootCmd.PersistentFlags().IntVar(&parallelRequests, "parallel", 1, "Number of messages to be consumed in parallel")
91+
RootCmd.PersistentFlags().IntVar(&port, "port", 8090, "Port used by metrics server")
8992

9093
httpClient = &http.Client{}
9194
}
@@ -128,7 +131,7 @@ func startGohaqd(cmd *cobra.Command, args []string) {
128131
}
129132

130133
http.Handle("/metrics", promhttp.Handler())
131-
log.Fatal(http.ListenAndServe(":8080", nil))
134+
log.Fatal(http.ListenAndServe(":"+fmt.Sprint(port), nil))
132135
}
133136

134137
func initializeQueue(queue Queue) {

0 commit comments

Comments
 (0)