aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-01-26 14:24:59 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2026-01-26 14:24:59 +0100
commitf1d501e90d67613952d5dc4639f2d52b51e5076c (patch)
tree5f690e8390eb6e6d79ffffde07ce69faa7eeb6dd
parent970fffc0cc7a3ee898df8ee5838a512c52d96df7 (diff)
downloadticket-counter-f1d501e90d67613952d5dc4639f2d52b51e5076c.tar.gz
ticket-counter-f1d501e90d67613952d5dc4639f2d52b51e5076c.zip
make port configurable on the commandline
-rw-r--r--main.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/main.go b/main.go
index 8754dd6..a8d897d 100644
--- a/main.go
+++ b/main.go
@@ -2,6 +2,7 @@ package main
import (
_ "embed"
+ "flag"
"fmt"
"html/template"
"log"
@@ -171,8 +172,11 @@ func doneHandler(w http.ResponseWriter, r *http.Request) {
}
}
+var port = flag.Int("p", 8080, "the port to use")
+
func main() {
- // Make a new Broker instance
+ flag.Parse()
+
broker = &Broker{
make(map[chan string]bool),
make(chan (chan string)),
@@ -180,7 +184,6 @@ func main() {
make(chan string),
}
- // Start processing events
broker.Start()
pageTemplate = template.Must(template.New("index").Parse(indexTemplate))
@@ -190,7 +193,7 @@ func main() {
http.HandleFunc("/done", doneHandler)
http.Handle("/events", broker)
- log.Printf("Serving http on %d", 8080)
+ log.Printf("Serving http on %d\n", *port)
err := http.ListenAndServe(fmt.Sprintf(":%d", 8080), nil)
log.Panicf("Serving http failed with %s", err)
}