summaryrefslogtreecommitdiff
path: root/daemon.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-22 01:50:15 -0500
committerJeff Carr <[email protected]>2025-09-22 01:50:15 -0500
commit3a786d60fd86802fc6e3fa2f0cc12c02a1751e85 (patch)
tree6a4d7f2bb19a32da29a0f7f1cb6ec78175797812 /daemon.go
parentaeae4ddf46cf577283a4b65fa4ffacd8f9d6cc8e (diff)
adding url debuggingv0.0.93
Diffstat (limited to 'daemon.go')
-rw-r--r--daemon.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/daemon.go b/daemon.go
new file mode 100644
index 0000000..f92907f
--- /dev/null
+++ b/daemon.go
@@ -0,0 +1,46 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+import (
+ "fmt"
+ "os"
+ "time"
+)
+
+// timeFunction takes a function as an argument and returns the execution time.
+func TimeFunction(f func()) time.Duration {
+ startTime := time.Now() // Record the start time
+ f() // Execute the function
+ return time.Since(startTime) // Calculate the elapsed time
+}
+
+// sends updates to zookeeper
+func zood() {
+ me.dog = time.NewTicker(me.pollDelay)
+ defer me.dog.Stop()
+ done := make(chan bool)
+ for {
+ select {
+ case <-done:
+ fmt.Println("Done!")
+ return
+ case _ = <-me.dog.C:
+ s := me.machine.UpdatePackages()
+ me.failcount += 1
+ sendMachine(s)
+
+ if me.failcount > 20 {
+ os.Exit(0)
+ }
+ }
+ }
+ /*
+ // this example would exit/destroy the ticker in 10 seconds
+ go func() {
+ time.Sleep(10 * time.Second)
+ done <- true
+ }()
+ */
+}