Compare commits

...

2 Commits

Author SHA1 Message Date
Jack M. 18f72700b6
Merge 7b023a3e8e into 15768ee0ab 2025-02-11 15:13:55 +01:00
Jack M. 7b023a3e8e
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.
2025-01-25 06:42:39 -07:00
1 changed files with 2 additions and 0 deletions

2
ntp.go
View File

@ -20,6 +20,8 @@ func TimeSyncLoop() {
err := SyncSystemTime() err := SyncSystemTime()
if err != nil { if err != nil {
log.Printf("Failed to sync system time: %v", err) 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 continue
} }
log.Printf("Time sync successful, now is: %v, time taken: %v", time.Now(), time.Since(start)) log.Printf("Time sync successful, now is: %v, time taken: %v", time.Now(), time.Since(start))