From 0ef59df97e7f1bd56c03ada462b9cff794ce4b91 Mon Sep 17 00:00:00 2001 From: skanehira Date: Tue, 8 Oct 2019 01:55:04 +0900 Subject: [PATCH] Fix log stream did not close when stopped monitoring log. --- gui/keybindings.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gui/keybindings.go b/gui/keybindings.go index e11346c..fde809c 100644 --- a/gui/keybindings.go +++ b/gui/keybindings.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "io" "os" "os/signal" "path/filepath" @@ -670,8 +671,11 @@ func (g *Gui) tailContainerLog() { signal.Notify(sigint, os.Interrupt) errCh := make(chan error) + var reader io.ReadCloser + var err error + go func() { - reader, err := docker.Client.ContainerLogStream(container.ID) + reader, err = docker.Client.ContainerLogStream(container.ID) if err != nil { common.Logger.Error(err) errCh <- err @@ -689,8 +693,10 @@ func (g *Gui) tailContainerLog() { select { case err := <-errCh: common.Logger.Error(err) + reader.Close() return case <-sigint: + reader.Close() return } }) {