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.
This commit is contained in:
Jack M. 2025-01-25 06:35:44 -07:00
parent 8ffe66a1bc
commit 7b023a3e8e
No known key found for this signature in database
1 changed files with 2 additions and 0 deletions

2
ntp.go
View File

@ -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))