Skip to content

Commit

Permalink
Adding support for docker max restart time
Browse files Browse the repository at this point in the history
Signed-off-by: milindchawre <[email protected]>
  • Loading branch information
milindchawre committed Feb 4, 2017
1 parent d6b1b53 commit 9bd3a7c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions restartmanager/restartmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
const (
backoffMultiplier = 2
defaultTimeout = 100 * time.Millisecond
maxRestartTimeout = 1 * time.Minute
)

// ErrRestartCanceled is returned when the restart manager has been
Expand Down Expand Up @@ -70,11 +71,15 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
if executionDuration.Seconds() >= 10 {
rm.timeout = 0
}
if rm.timeout == 0 {
switch {
case rm.timeout == 0:
rm.timeout = defaultTimeout
} else {
case rm.timeout < maxRestartTimeout:
rm.timeout *= backoffMultiplier
}
if rm.timeout > maxRestartTimeout {
rm.timeout = maxRestartTimeout
}

var restart bool
switch {
Expand Down

0 comments on commit 9bd3a7c

Please sign in to comment.