Proper sleep logic when errors occur. Also better logging
This commit is contained in:
parent
e18f181cde
commit
2cbcb510b5
1 changed files with 9 additions and 3 deletions
|
@ -32,7 +32,9 @@ func runConfig(c api.Config, daemon bool) {
|
|||
if err != nil {
|
||||
log.Logger.Print("Failed to retreive IP: ")
|
||||
if daemon {
|
||||
log.Logger.Println("Will retry...")
|
||||
log.Logger.Printf("Will retry in %d seconds...\n", c.Interval)
|
||||
time.Sleep(time.Duration(c.Interval) * time.Second)
|
||||
|
||||
continue
|
||||
} else {
|
||||
log.Logger.Println("Giving up.")
|
||||
|
@ -46,9 +48,11 @@ func runConfig(c api.Config, daemon bool) {
|
|||
// update it.
|
||||
records, err := a.GetDNSRecords(c.Domain)
|
||||
if err != nil {
|
||||
log.Logger.Printf("Failed to retreive records for%s\n", c.Domain)
|
||||
log.Logger.Printf("Failed to retreive records for %s:\n\t%s\n", c.Domain, err)
|
||||
if daemon {
|
||||
log.Logger.Print("Will retry...")
|
||||
log.Logger.Printf("Will retry in %d seconds...\n", c.Interval)
|
||||
time.Sleep(time.Duration(c.Interval) * time.Second)
|
||||
|
||||
continue
|
||||
} else {
|
||||
log.Logger.Print("Giving up.")
|
||||
|
@ -68,10 +72,12 @@ func runConfig(c api.Config, daemon bool) {
|
|||
}
|
||||
}
|
||||
|
||||
log.Logger.Println("Update complete.")
|
||||
if !daemon {
|
||||
log.Logger.Println("Non daemon mode, stopping.")
|
||||
return
|
||||
}
|
||||
log.Logger.Printf("Will update again in %d seconds.\n", c.Interval)
|
||||
|
||||
time.Sleep(time.Duration(c.Interval) * time.Second)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue