Skip to content

Commit

Permalink
feat: allow public port specified in CLI flag
Browse files Browse the repository at this point in the history
Specify a custom port for listening with a default of 8080.
  • Loading branch information
particledecay committed Jan 26, 2022
1 parent 4257cd9 commit e984d38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.verbose }}
args:
- -verbose
{{- end }}
- "-port {{ .Values.service.public.port }}"
{{- if .Values.verbose }}
- "-verbose"
{{- end }}
ports:
- name: internal
containerPort: {{ .Values.service.internal.port }}
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"flag"
"fmt"
"net/http"
"strconv"
"time"
Expand Down Expand Up @@ -113,6 +114,7 @@ func setHeartRateSeconds(w http.ResponseWriter, r *http.Request) {

func main() {
verbose := flag.Bool("verbose", false, "show debug messages")
listenPort := flag.Int("port", 8080, "listen port for server")
flag.Parse()

log.SetFormatter(&log.JSONFormatter{})
Expand All @@ -138,5 +140,5 @@ func main() {
http.ListenAndServe(":9090", internalMux)
}()
log.Info("Listening for heartbeat changes.")
http.ListenAndServe(":8080", mainMux)
http.ListenAndServe(fmt.Sprintf(":%d", *listenPort), mainMux)
}

0 comments on commit e984d38

Please sign in to comment.