From 0f7a4534c16cda07344a7231d6012268f4aa53aa Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 29 Mar 2013 08:46:06 -0700 Subject: [PATCH] Do not log non-running containers --- container.go | 8 ++++++++ runtime.go | 9 +-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/container.go b/container.go index c0175b96b1..629af3a039 100644 --- a/container.go +++ b/container.go @@ -256,6 +256,14 @@ func (container *Container) Start() error { container.Config.Env..., ) + // Setup logging of stdout and stderr to disk + if err := container.runtime.LogToDisk(container.stdout, container.logPath("stdout")); err != nil { + return err + } + if err := container.runtime.LogToDisk(container.stderr, container.logPath("stderr")); err != nil { + return err + } + var err error if container.Config.Tty { container.cmd.Env = append( diff --git a/runtime.go b/runtime.go index c719fdd602..37726da0ec 100644 --- a/runtime.go +++ b/runtime.go @@ -140,13 +140,6 @@ func (runtime *Runtime) Register(container *Container) error { } else { container.stdinPipe = NopWriteCloser(ioutil.Discard) // Silently drop stdin } - // Setup logging of stdout and stderr to disk - if err := runtime.LogToDisk(container.stdout, container.logPath("stdout")); err != nil { - return err - } - if err := runtime.LogToDisk(container.stderr, container.logPath("stderr")); err != nil { - return err - } // done runtime.containers.PushBack(container) return nil @@ -157,7 +150,7 @@ func (runtime *Runtime) LogToDisk(src *writeBroadcaster, dst string) error { if err != nil { return err } - src.AddWriter(NopWriteCloser(log)) + src.AddWriter(log) return nil }