Add reset endpoint

This commit is contained in:
Sebastiaan de Schaetzen 2025-04-02 10:25:52 +02:00
parent 5d07060a78
commit cc20e1c09a

10
main.go
View File

@ -148,6 +148,7 @@ func startHTTPServer() *http.Server {
} }
http.HandleFunc("/status", handleStatus) http.HandleFunc("/status", handleStatus)
http.HandleFunc("/reset", handleReset)
go func() { go func() {
if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
@ -176,6 +177,15 @@ func handleStatus(w http.ResponseWriter, _ *http.Request) {
} }
} }
func handleReset(w http.ResponseWriter, _ *http.Request) {
statusMutex.Lock()
defer statusMutex.Unlock()
nextSleepTime = time.Now().Add(monitoringPeriod)
blockers = []string{"blocked by HTTP"}
w.WriteHeader(http.StatusOK)
}
func updateSystemStatus() { func updateSystemStatus() {
statusMutex.Lock() statusMutex.Lock()
defer statusMutex.Unlock() defer statusMutex.Unlock()