Browse code

Do not log non-running containers

Guillaume J. Charmes authored on 2013/03/30 00:46:06
Showing 2 changed files
... ...
@@ -256,6 +256,14 @@ func (container *Container) Start() error {
256 256
 		container.Config.Env...,
257 257
 	)
258 258
 
259
+	// Setup logging of stdout and stderr to disk
260
+	if err := container.runtime.LogToDisk(container.stdout, container.logPath("stdout")); err != nil {
261
+		return err
262
+	}
263
+	if err := container.runtime.LogToDisk(container.stderr, container.logPath("stderr")); err != nil {
264
+		return err
265
+	}
266
+
259 267
 	var err error
260 268
 	if container.Config.Tty {
261 269
 		container.cmd.Env = append(
... ...
@@ -140,13 +140,6 @@ func (runtime *Runtime) Register(container *Container) error {
140 140
 	} else {
141 141
 		container.stdinPipe = NopWriteCloser(ioutil.Discard) // Silently drop stdin
142 142
 	}
143
-	// Setup logging of stdout and stderr to disk
144
-	if err := runtime.LogToDisk(container.stdout, container.logPath("stdout")); err != nil {
145
-		return err
146
-	}
147
-	if err := runtime.LogToDisk(container.stderr, container.logPath("stderr")); err != nil {
148
-		return err
149
-	}
150 143
 	// done
151 144
 	runtime.containers.PushBack(container)
152 145
 	return nil
... ...
@@ -157,7 +150,7 @@ func (runtime *Runtime) LogToDisk(src *writeBroadcaster, dst string) error {
157 157
 	if err != nil {
158 158
 		return err
159 159
 	}
160
-	src.AddWriter(NopWriteCloser(log))
160
+	src.AddWriter(log)
161 161
 	return nil
162 162
 }
163 163