summaryrefslogtreecommitdiff
path: root/internal/sdnotify/sdnotify.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/sdnotify/sdnotify.go')
-rw-r--r--internal/sdnotify/sdnotify.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/sdnotify/sdnotify.go b/internal/sdnotify/sdnotify.go
index aed38c92..d88c0e88 100644
--- a/internal/sdnotify/sdnotify.go
+++ b/internal/sdnotify/sdnotify.go
@@ -25,6 +25,7 @@ package sdnotify
import (
"net"
"os"
+ "time"
)
type State string
@@ -84,3 +85,19 @@ func SdNotify(state State) (bool, error) {
return true, nil
}
+
+func StartWatchdog(interval int, stopCh chan struct{}) {
+ go func() {
+ ticker := time.NewTicker(time.Duration(interval) * time.Second)
+ defer ticker.Stop()
+
+ for {
+ select {
+ case <-stopCh:
+ return
+ case <-ticker.C:
+ _, _ = SdNotify(Watchdog)
+ }
+ }
+ }()
+}