From 2d12f1d9a8ec4a6604dc4de119aace633043b29e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 28 Jun 2026 15:44:06 +0200 Subject: use the server startup time to drop old cached tickets --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index adcb194..aa5b52b 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "net/http" "strconv" "sync/atomic" + "time" ) //go:embed index.html @@ -18,6 +19,7 @@ var pageTemplate *template.Template var open atomic.Uint64 var done atomic.Uint64 +var start time.Time var broker *Broker @@ -144,10 +146,11 @@ func pageHandler(w http.ResponseWriter, r *http.Request) { } tempData := struct { - Open uint64 - Done uint64 - IsAdmin bool - }{open.Load(), done.Load() + 1, r.URL.Query().Has(*passwd)} + Open uint64 + Done uint64 + StartTime string + IsAdmin bool + }{open.Load(), done.Load() + 1, start.Format(time.RFC3339), r.URL.Query().Has(*passwd)} if err := pageTemplate.Execute(w, tempData); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -178,6 +181,8 @@ var passwd = flag.String("password", "admin", "the admin password") func main() { flag.Parse() + start = time.Now() + broker = &Broker{ make(map[chan string]bool), make(chan (chan string)), -- cgit v1.2.3