diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-01-26 14:24:59 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-01-26 14:24:59 +0100 |
| commit | f1d501e90d67613952d5dc4639f2d52b51e5076c (patch) | |
| tree | 5f690e8390eb6e6d79ffffde07ce69faa7eeb6dd /main.go | |
| parent | 970fffc0cc7a3ee898df8ee5838a512c52d96df7 (diff) | |
| download | ticket-counter-f1d501e90d67613952d5dc4639f2d52b51e5076c.tar.gz ticket-counter-f1d501e90d67613952d5dc4639f2d52b51e5076c.zip | |
make port configurable on the commandline
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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) } |
