From 1627c1aea8ccf7a7d08469d0983b9aa96cb7c5b3 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Mon, 17 Jan 2022 10:48:32 +0100 Subject: [PATCH] Added content server check ticker --- FinalCommander.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/FinalCommander.go b/FinalCommander.go index 4322242..045e454 100644 --- a/FinalCommander.go +++ b/FinalCommander.go @@ -45,7 +45,6 @@ type ContentServer struct { Address string Weight uint LastCheckResult bool - LastCheck time.Time LastCheckMutex sync.RWMutex } @@ -441,11 +440,8 @@ func handle(w http.ResponseWriter, r *http.Request) { } func checkContentServers() { - checkTime := time.Now().Add(-15 * time.Minute) for _, c := range contentServers { - if c.LastCheck.Before(checkTime) { - c.check() - } + c.check() } } @@ -507,13 +503,18 @@ func main() { Address: p[0], Weight: uint(weight), LastCheckResult: false, - LastCheck: time.Date(1970, 0, 0, 0, 0, 0, 0, time.UTC), }) } - //TODO: cron this checkContentServers() + go func() { + ticker := time.NewTicker(1 * time.Minute) + for _ = range ticker.C { + checkContentServers() + } + }() + sniAddress = strings.ToLower(*sniAddressOption) bogusCertificatePEM, bogusKeyPairPEM := createSelfSignedCertificate()