Skip to content

Commit

Permalink
delay between restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
spilin committed Jan 29, 2025
1 parent 3a79907 commit bf38ed5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"strings"
"sync"
"time"

"blockscout-vc/internal/docker"
)
Expand Down Expand Up @@ -70,7 +71,6 @@ func (w *Worker) process(ctx context.Context) {
case job := <-w.jobs:
jobKey := w.makeKey(job.Containers)
// Using an immediately invoked function to ensure defer runs after each job
// Without this, defer would only run when the process function returns
func() {
defer func() {
w.jobSetMux.Lock()
Expand All @@ -83,6 +83,15 @@ func (w *Worker) process(ctx context.Context) {
log.Printf("failed to recreate containers: %v", err)
return
}

// Add mandatory delay after successful recreation
log.Printf("Container recreation completed, waiting 10 seconds before next job...")
select {
case <-ctx.Done():
return
case <-time.After(10 * time.Second):
// Continue to next job after delay
}
}()
}
}
Expand Down

0 comments on commit bf38ed5

Please sign in to comment.