From ea052ffae007533694ebd0b74b3c33f7621e36ed Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Mon, 9 Dec 2019 00:49:25 -0800 Subject: [PATCH] add a retry --- integrations/inputunifi/pkg/poller/start.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integrations/inputunifi/pkg/poller/start.go b/integrations/inputunifi/pkg/poller/start.go index a4953475..c15afddf 100644 --- a/integrations/inputunifi/pkg/poller/start.go +++ b/integrations/inputunifi/pkg/poller/start.go @@ -116,20 +116,23 @@ func (u *UnifiPoller) Run() error { // PollController runs forever, polling UniFi and pushing to InfluxDB // This is started by Run() or RunBoth() after everything checks out. func (u *UnifiPoller) PollController() { + var tryAgain bool interval := u.Config.Interval.Round(time.Second) log.Printf("[INFO] Everything checks out! Poller started, InfluxDB interval: %v", interval) ticker := time.NewTicker(interval) for u.LastCheck = range ticker.C { // Some users need to re-auth every interval because the cookie times out. - if u.Config.ReAuth { + if u.Config.ReAuth || tryAgain { u.LogDebugf("Re-authenticating to UniFi Controller") if err := u.Unifi.Login(); err != nil { u.LogErrorf("%v", err) continue } + tryAgain = false } if err := u.CollectAndProcess(); err != nil { u.LogErrorf("%v", err) + tryAgain = true } } }