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()
|
updateCurrentUsage()
|
||||||
blocked, _ := getBlockers()
|
blocked, _ := getBlockers()
|
||||||
if blocked {
|
if blocked {
|
||||||
nextSleepTime = time.Now().Add(monitoringPeriod)
|
delaySleep()
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Now().After(nextSleepTime) {
|
if time.Now().After(nextSleepTime) {
|
||||||
@ -186,6 +186,8 @@ func handleReset(w http.ResponseWriter, _ *http.Request) {
|
|||||||
statusMutex.Lock()
|
statusMutex.Lock()
|
||||||
defer statusMutex.Unlock()
|
defer statusMutex.Unlock()
|
||||||
|
|
||||||
|
delaySleep()
|
||||||
|
|
||||||
currentStatus.HttpRequests++
|
currentStatus.HttpRequests++
|
||||||
nextSleepTime = time.Now().Add(monitoringPeriod)
|
nextSleepTime = time.Now().Add(monitoringPeriod)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
@ -364,3 +366,7 @@ func suspendSystem() error {
|
|||||||
cmd := exec.Command("systemctl", "suspend")
|
cmd := exec.Command("systemctl", "suspend")
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func delaySleep() {
|
||||||
|
nextSleepTime = time.Now().Add(monitoringPeriod)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user