Browse code

Deprecate --restart on the daemon

Signed-off-by: Michael Crosby <michael@docker.com>

Michael Crosby authored on 2014/08/14 06:58:57
Showing 5 changed files
... ...
@@ -45,7 +45,7 @@ type Config struct {
45 45
 func (config *Config) InstallFlags() {
46 46
 	flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
47 47
 	flag.StringVar(&config.Root, []string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime")
48
-	flag.BoolVar(&config.AutoRestart, []string{"r", "-restart"}, true, "Restart previously running containers")
48
+	flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated infavor of --restart policies on docker run")
49 49
 	flag.BoolVar(&config.EnableIptables, []string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules")
50 50
 	flag.BoolVar(&config.EnableIpForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
51 51
 	flag.StringVar(&config.BridgeIP, []string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b")
... ...
@@ -372,10 +372,10 @@ func (daemon *Daemon) restore() error {
372 372
 		for _, container := range registeredContainers {
373 373
 			if container.hostConfig.RestartPolicy.Name == "always" ||
374 374
 				(container.hostConfig.RestartPolicy.Name == "on-failure" && container.State.ExitCode != 0) {
375
-				utils.Debugf("Starting container %s", container.ID)
375
+				log.Debugf("Starting container %s", container.ID)
376 376
 
377 377
 				if err := container.Start(); err != nil {
378
-					utils.Debugf("Failed to start container %s: %s", container.ID, err)
378
+					log.Debugf("Failed to start container %s: %s", container.ID, err)
379 379
 				}
380 380
 			}
381 381
 		}
... ...
@@ -7,8 +7,8 @@ import (
7 7
 	"time"
8 8
 
9 9
 	"github.com/docker/docker/daemon/execdriver"
10
+	"github.com/docker/docker/pkg/log"
10 11
 	"github.com/docker/docker/runconfig"
11
-	"github.com/docker/docker/utils"
12 12
 )
13 13
 
14 14
 const defaultTimeIncrement = 100
... ...
@@ -88,7 +88,7 @@ func (m *containerMonitor) Close() error {
88 88
 	// because they share same runconfig and change image. Must be fixed
89 89
 	// in builder/builder.go
90 90
 	if err := m.container.toDisk(); err != nil {
91
-		utils.Errorf("Error dumping container %s state to disk: %s\n", m.container.ID, err)
91
+		log.Errorf("Error dumping container %s state to disk: %s\n", m.container.ID, err)
92 92
 
93 93
 		return err
94 94
 	}
... ...
@@ -127,13 +127,13 @@ func (m *containerMonitor) Start() error {
127 127
 		if exitStatus, err = m.container.daemon.Run(m.container, pipes, m.callback); err != nil {
128 128
 			// if we receive an internal error from the initial start of a container then lets
129 129
 			// return it instead of entering the restart loop
130
-			if m.container.RestartCount == 1 {
130
+			if m.container.RestartCount == 0 {
131 131
 				m.resetContainer()
132 132
 
133 133
 				return err
134 134
 			}
135 135
 
136
-			utils.Errorf("Error running container: %s", err)
136
+			log.Errorf("Error running container: %s", err)
137 137
 		}
138 138
 
139 139
 		m.resetMonitor(err == nil && exitStatus == 0)
... ...
@@ -220,7 +220,7 @@ func (m *containerMonitor) shouldRestart(exitStatus int) bool {
220 220
 	case "on-failure":
221 221
 		// the default value of 0 for MaximumRetryCount means that we will not enforce a maximum count
222 222
 		if max := m.restartPolicy.MaximumRetryCount; max != 0 && m.failureCount >= max {
223
-			utils.Debugf("stopping restart of container %s because maximum failure could of %d has been reached", max)
223
+			log.Debugf("stopping restart of container %s because maximum failure could of %d has been reached", max)
224 224
 			return false
225 225
 		}
226 226
 
... ...
@@ -251,7 +251,7 @@ func (m *containerMonitor) callback(command *execdriver.Command) {
251 251
 	}
252 252
 
253 253
 	if err := m.container.ToDisk(); err != nil {
254
-		utils.Debugf("%s", err)
254
+		log.Debugf("%s", err)
255 255
 	}
256 256
 }
257 257
 
... ...
@@ -262,21 +262,21 @@ func (m *containerMonitor) resetContainer() {
262 262
 
263 263
 	if container.Config.OpenStdin {
264 264
 		if err := container.stdin.Close(); err != nil {
265
-			utils.Errorf("%s: Error close stdin: %s", container.ID, err)
265
+			log.Errorf("%s: Error close stdin: %s", container.ID, err)
266 266
 		}
267 267
 	}
268 268
 
269 269
 	if err := container.stdout.Clean(); err != nil {
270
-		utils.Errorf("%s: Error close stdout: %s", container.ID, err)
270
+		log.Errorf("%s: Error close stdout: %s", container.ID, err)
271 271
 	}
272 272
 
273 273
 	if err := container.stderr.Clean(); err != nil {
274
-		utils.Errorf("%s: Error close stderr: %s", container.ID, err)
274
+		log.Errorf("%s: Error close stderr: %s", container.ID, err)
275 275
 	}
276 276
 
277 277
 	if container.command != nil && container.command.Terminal != nil {
278 278
 		if err := container.command.Terminal.Close(); err != nil {
279
-			utils.Errorf("%s: Error closing terminal: %s", container.ID, err)
279
+			log.Errorf("%s: Error closing terminal: %s", container.ID, err)
280 280
 		}
281 281
 	}
282 282
 
... ...
@@ -64,9 +64,6 @@ unix://[/path/to/socket] to use.
64 64
 **-p**=""
65 65
   Path to use for daemon PID file. Default is `/var/run/docker.pid`
66 66
 
67
-**-r**=*true*|*false*
68
-  Restart previously running containers. Default is true.
69
-
70 67
 **-s**=""
71 68
   Force the Docker runtime to use a specific storage driver.
72 69
 
... ...
@@ -71,7 +71,6 @@ expect an integer, and they can only be specified once.
71 71
       --mtu=0                                    Set the containers network MTU
72 72
                                                    if no value is provided: default to the default route MTU or 1500 if no default route is available
73 73
       -p, --pidfile="/var/run/docker.pid"        Path to use for daemon PID file
74
-      -r, --restart=true                         Restart previously running containers
75 74
       -s, --storage-driver=""                    Force the Docker runtime to use a specific storage driver
76 75
       --selinux-enabled=false                    Enable selinux support. SELinux does not presently support the BTRFS storage driver
77 76
       --storage-opt=[]                           Set storage driver options