Reintroduce delay in reset
This commit is contained in:
parent
852390a354
commit
e8d8590d03
8
main.go
8
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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user