Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
client: fix restart cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
sarisia committed Apr 24, 2020
1 parent bc79253 commit 31c996b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions aria/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ func (l *launcher) launchBot(ctx context.Context, errChan chan<- error) {
func (l *launcher) launchClient(ctx context.Context, errChan chan<- error) {
var start time.Time
for {
if time.Now().Sub(start) < 5*time.Minute {
log.Printf("client cooldown: 1min...")
// do restart cooldown
if start != (time.Time{}) { // avoid cooldown for first launch
cooldown := 10 * time.Second
if time.Now().Sub(start) < 5*time.Minute {
cooldown = time.Minute
}

log.Printf("client cooldown: %v...", cooldown)
select {
case <-ctx.Done():
log.Printf("launch cancelled: client")
return
case <-time.After(time.Minute):
case <-time.After(cooldown):
}
}

Expand Down

0 comments on commit 31c996b

Please sign in to comment.