routines: RestartDeadline defaults to 32 seconds

This commit is contained in:
Sasha Koshka 2024-11-03 19:13:25 -05:00
parent 816c3e1fc3
commit ba7983c375

View File

@ -46,6 +46,7 @@ type Manager struct {
// RestartDeadline specifies the amount of time a routine has to be
// running before failing to be restarted. This is to prevent routines
// that immediately fail from just being restarted over and over again.
// Defaults to 32 seconds if not set.
RestartDeadline time.Duration
// Logger, if non-nil, is where log messages will be written to. If it
@ -123,6 +124,11 @@ func (this *Manager) initRoutine (routine Routine, group *sync.WaitGroup) {
func (this *Manager) runRoutine (routine Routine, group *sync.WaitGroup) {
defer group.Done()
restartDeadline := this.RestartDeadline
if restartDeadline == 0 {
restartDeadline = 32 * time.Second
}
for {
lastStart := time.Now()
err := panicWrap(routine.Run, this.ctx)