diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-15 13:57:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 13:57:13 -0400 |
commit | 8a42a32c71431194cd6945bf2b88c8a278803280 (patch) | |
tree | ebd9b6005ab92398a2575efca476589fcd9e06bd /libpod | |
parent | 5a82a559c6b58833df8fc02a589e9f349a053e16 (diff) | |
parent | 6d9863e7738719a100ac56c1e646c169e4c0bd11 (diff) | |
download | podman-8a42a32c71431194cd6945bf2b88c8a278803280.tar.gz podman-8a42a32c71431194cd6945bf2b88c8a278803280.tar.bz2 podman-8a42a32c71431194cd6945bf2b88c8a278803280.zip |
Merge pull request #6591 from jgallucci32/patch-1
Merged request to fix -f to stop following logs
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_log.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libpod/container_log.go b/libpod/container_log.go index c3a84d048..39c395fe6 100644 --- a/libpod/container_log.go +++ b/libpod/container_log.go @@ -2,6 +2,7 @@ package libpod import ( "os" + "time" "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/logs" @@ -72,5 +73,27 @@ func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *l } options.WaitGroup.Done() }() + // Check if container is still running or paused + go func() { + if options.Follow { + for { + state, err := c.State() + if err != nil && errors.Cause(err) != define.ErrNoSuchCtr { + logrus.Error(err) + break + } else if err != nil { + break + } + if state != define.ContainerStateRunning && state != define.ContainerStatePaused { + err := t.Stop() + if err != nil { + logrus.Error(err) + } + break + } + time.Sleep(1 * time.Second) + } + } + }() return nil } |