routines: RestartDeadline defaults to 32 seconds
This commit is contained in:
parent
816c3e1fc3
commit
ba7983c375
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user