Close logs pipes and catch write errors
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
fd3f2e175f
commit
a7ee201ee8
|
@ -114,12 +114,14 @@ func (daemon *Daemon) ContainerLogs(job *engine.Job) engine.Status {
|
||||||
errors := make(chan error, 2)
|
errors := make(chan error, 2)
|
||||||
if stdout {
|
if stdout {
|
||||||
stdoutPipe := container.StdoutLogPipe()
|
stdoutPipe := container.StdoutLogPipe()
|
||||||
|
defer stdoutPipe.Close()
|
||||||
go func() {
|
go func() {
|
||||||
errors <- jsonlog.WriteLog(stdoutPipe, job.Stdout, format)
|
errors <- jsonlog.WriteLog(stdoutPipe, job.Stdout, format)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if stderr {
|
if stderr {
|
||||||
stderrPipe := container.StderrLogPipe()
|
stderrPipe := container.StderrLogPipe()
|
||||||
|
defer stderrPipe.Close()
|
||||||
go func() {
|
go func() {
|
||||||
errors <- jsonlog.WriteLog(stderrPipe, job.Stderr, format)
|
errors <- jsonlog.WriteLog(stderrPipe, job.Stderr, format)
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -40,6 +40,8 @@ func WriteLog(src io.Reader, dst io.Writer, format string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(dst, "%s", line)
|
if _, err := io.WriteString(dst, line); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue