Reintroduce delay in reset

This commit is contained in:
Sebastiaan de Schaetzen 2025-04-09 10:40:51 +02:00
parent 852390a354
commit e8d8590d03

View File

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