From b88cca4b0d5f8948e682d6c70752c23ec7808d53 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 25 Jan 2024 18:16:51 -0600 Subject: checkbox state works Signed-off-by: Jeff Carr --- watchdog.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'watchdog.go') diff --git a/watchdog.go b/watchdog.go index 02e7a2f..07a1dee 100644 --- a/watchdog.go +++ b/watchdog.go @@ -17,9 +17,37 @@ This goroutine can be used like a watchdog timer */ func Watchdog() { var i = 1 + /* for { log.Verbose("gui.Watchdog() is alive. give me something to do.", i) - i += 1 time.Sleep(watchtime * time.Second / 10) } + */ + // check the four known things to see if they are all WORKING + myTicker(3*time.Second, "WATCHDOG", func() { + i += 1 + log.Log(INFO, "myTicker() ticked", i) + }) +} + +func myTicker(t time.Duration, name string, f func()) { + ticker := time.NewTicker(t) + defer ticker.Stop() + done := make(chan bool) + /* + go func() { + time.Sleep(10 * time.Second) + done <- true + }() + */ + for { + select { + case <-done: + log.Warn("gui.Watchdog() Done!") + return + case t := <-ticker.C: + log.Log(INFO, name, "Current time: ", t) + f() + } + } } -- cgit v1.2.3