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) +}