From 7b023a3e8e49aecbd673d9cb8f3862807d0462eb Mon Sep 17 00:00:00 2001 From: "Jack M." Date: Sat, 25 Jan 2025 06:35:44 -0700 Subject: [PATCH] fix: NTP requests sleep for 1 hour between attempts. Fixes #74 - When the device is unable to connect to the time servers, it was looping every two seconds. This lead to unecessary processing, and if the device was able to connect to DNS but not the time servers, it was causing undue load on the DNS server as well. --- ntp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ntp.go b/ntp.go index f785d96..b19826c 100644 --- a/ntp.go +++ b/ntp.go @@ -20,6 +20,8 @@ func TimeSyncLoop() { err := SyncSystemTime() if err != nil { log.Printf("Failed to sync system time: %v", err) + // Sync failed for all 4 endpoints, likely network issue, wait for 1 hour before retrying + time.Sleep(1 * time.Hour) continue } log.Printf("Time sync successful, now is: %v, time taken: %v", time.Now(), time.Since(start))