diff --git a/routines/routines.go b/routines/routines.go index 0b67e1c..dd48101 100644 --- a/routines/routines.go +++ b/routines/routines.go @@ -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)