mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 15:28:35 +00:00
Add RestartPolicy methods instead of using strings checking
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
+2
-2
@@ -325,8 +325,8 @@ func (daemon *Daemon) restore() error {
|
||||
logrus.Debug("Restarting containers...")
|
||||
|
||||
for _, container := range registeredContainers {
|
||||
if container.hostConfig.RestartPolicy.Name == "always" ||
|
||||
(container.hostConfig.RestartPolicy.Name == "on-failure" && container.ExitCode != 0) {
|
||||
if container.hostConfig.RestartPolicy.IsAlways() ||
|
||||
(container.hostConfig.RestartPolicy.IsOnFailure() && container.ExitCode != 0) {
|
||||
logrus.Debugf("Starting container %s", container.ID)
|
||||
|
||||
if err := container.Start(); err != nil {
|
||||
|
||||
+3
-3
@@ -223,10 +223,10 @@ func (m *containerMonitor) shouldRestart(exitCode int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
switch m.restartPolicy.Name {
|
||||
case "always":
|
||||
switch {
|
||||
case m.restartPolicy.IsAlways():
|
||||
return true
|
||||
case "on-failure":
|
||||
case m.restartPolicy.IsOnFailure():
|
||||
// the default value of 0 for MaximumRetryCount means that we will not enforce a maximum count
|
||||
if max := m.restartPolicy.MaximumRetryCount; max != 0 && m.failureCount > max {
|
||||
logrus.Debugf("stopping restart of container %s because maximum failure could of %d has been reached",
|
||||
|
||||
Reference in New Issue
Block a user