Skip to content

Commit

Permalink
Wait between loops when monitoring a channel if an attempt exits early
Browse files Browse the repository at this point in the history
Should fix #173
  • Loading branch information
Kethsar committed Feb 1, 2024
1 parent 5d91faa commit 9dbed6c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/signal"
"path/filepath"
"strings"
"time"

"github.com/alessio/shellescape"
)
Expand Down Expand Up @@ -1064,12 +1065,19 @@ func main() {
networkType = NetworkIPv6
}

lastExitTime := time.Now()
PrintVersion()
for {
retcode = run()
if cancelled || !monitorChannel || !info.LiveURL {
break
}

if time.Since(lastExitTime) < (time.Duration(info.RetrySecs) * time.Second) {
LogDebug("Last run exited before the set wait time. Waiting before running again...")
time.Sleep(time.Duration(info.RetrySecs) * time.Second)
}
lastExitTime = time.Now()
}

Exit(retcode)
Expand Down

0 comments on commit 9dbed6c

Please sign in to comment.