From ba7983c375296bcd0f06ac012f82885ac8f5a6d4 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 3 Nov 2024 19:13:25 -0500 Subject: [PATCH] routines: RestartDeadline defaults to 32 seconds --- routines/routines.go | 6 ++++++ 1 file changed, 6 insertions(+) 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)