mirror of
https://github.com/containers/podman.git
synced 2025-06-18 07:28:57 +08:00
podman logs -f: does not detect container stop or rm
If a container stops, we should stop the logging capability and gracefully exit. However, if the container pauses, we should allow the log to continue. Resolves issue: #435 Signed-off-by: baude <bbaude@redhat.com> Closes: #437 Approved by: baude
This commit is contained in:
@ -129,14 +129,14 @@ func logsCmd(c *cli.Context) error {
|
|||||||
defer file.Close()
|
defer file.Close()
|
||||||
reader := bufio.NewReader(file)
|
reader := bufio.NewReader(file)
|
||||||
if opts.follow {
|
if opts.follow {
|
||||||
followLog(reader, opts)
|
followLog(reader, opts, ctr)
|
||||||
} else {
|
} else {
|
||||||
dumpLog(reader, opts)
|
dumpLog(reader, opts)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func followLog(reader *bufio.Reader, opts logOptions) error {
|
func followLog(reader *bufio.Reader, opts logOptions, ctr *libpod.Container) error {
|
||||||
var cacheOutput []string
|
var cacheOutput []string
|
||||||
firstPass := false
|
firstPass := false
|
||||||
if opts.tail > 0 {
|
if opts.tail > 0 {
|
||||||
@ -161,6 +161,14 @@ func followLog(reader *bufio.Reader, opts logOptions) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
// Check if container is still running or paused
|
||||||
|
state, err := ctr.State()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if state != libpod.ContainerStateRunning && state != libpod.ContainerStatePaused {
|
||||||
|
break
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// exits
|
// exits
|
||||||
|
Reference in New Issue
Block a user