Maybe don't create an infinite loop
This commit is contained in:
parent
2059932ad9
commit
8fc17bd9c9
19
nun.go
19
nun.go
@ -33,21 +33,22 @@ func (n *nunWatch) Main() {
|
||||
case <-n.stop:
|
||||
return
|
||||
case <-ticker.C:
|
||||
if n.fail > 5 {
|
||||
log.Fatal("fail count too high; ending loop")
|
||||
return
|
||||
}
|
||||
if n.fail > 3 {
|
||||
log.Println("over three failures, increasing tick time by 5x")
|
||||
ticker.Reset(5 * time.Duration(n.timer) * time.Minute)
|
||||
break
|
||||
}
|
||||
|
||||
newPost, err := getNewestPost("LittleNuns")
|
||||
if err != nil {
|
||||
log.Printf("error getting newest post: %v", err)
|
||||
log.Println("skipping this cycle, incrementing fail count")
|
||||
n.fail++
|
||||
if n.fail > 5 {
|
||||
log.Fatal("fail count too high; ending loop")
|
||||
return
|
||||
} else if n.fail > 3 {
|
||||
log.Println("over three failures, increasing tick time by 5x")
|
||||
ticker.Reset(5 * time.Duration(n.timer) * time.Minute)
|
||||
break
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if n.fail != 0 {
|
||||
n.fail = 0
|
||||
|
Loading…
Reference in New Issue
Block a user