From e8d8590d037430faae4816fe6f69b6f61537da7b Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Wed, 9 Apr 2025 10:40:51 +0200 Subject: [PATCH] Reintroduce delay in reset --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 92e298c..32aaabf 100644 --- a/main.go +++ b/main.go @@ -111,7 +111,7 @@ mainLoop: updateCurrentUsage() blocked, _ := getBlockers() if blocked { - nextSleepTime = time.Now().Add(monitoringPeriod) + delaySleep() } if time.Now().After(nextSleepTime) { @@ -186,6 +186,8 @@ func handleReset(w http.ResponseWriter, _ *http.Request) { statusMutex.Lock() defer statusMutex.Unlock() + delaySleep() + currentStatus.HttpRequests++ nextSleepTime = time.Now().Add(monitoringPeriod) w.WriteHeader(http.StatusOK) @@ -364,3 +366,7 @@ func suspendSystem() error { cmd := exec.Command("systemctl", "suspend") return cmd.Run() } + +func delaySleep() { + nextSleepTime = time.Now().Add(monitoringPeriod) +}