diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-09-14 16:52:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-14 16:52:13 -0400 |
commit | 040555534532de45c84b8bcf09a6e6e59144b43b (patch) | |
tree | d68b35ff6f014f30a7beb308e85e111faa25ed40 /cmd/podman | |
parent | 8541ed41e4dde12173e9f488f136f216d099274e (diff) | |
parent | 9ec82caa3147d7afaf9361748661c8868194d132 (diff) | |
download | podman-040555534532de45c84b8bcf09a6e6e59144b43b.tar.gz podman-040555534532de45c84b8bcf09a6e6e59144b43b.tar.bz2 podman-040555534532de45c84b8bcf09a6e6e59144b43b.zip |
Merge pull request #1434 from rhatdan/wait
Add --interval flag to podman wait
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/run.go | 2 | ||||
-rw-r--r-- | cmd/podman/start.go | 2 | ||||
-rw-r--r-- | cmd/podman/wait.go | 16 |
3 files changed, 16 insertions, 4 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 3445daef5..7bdae3038 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -223,7 +223,7 @@ func runCmd(c *cli.Context) error { return err } - if ecode, err := ctr.Wait(); err != nil { + if ecode, err := ctr.Wait(libpod.WaitTimeout); err != nil { if errors.Cause(err) == libpod.ErrNoSuchCtr { // The container may have been removed // Go looking for an exit file diff --git a/cmd/podman/start.go b/cmd/podman/start.go index cb65ec6d4..a80d0e1e8 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -115,7 +115,7 @@ func startCmd(c *cli.Context) error { return errors.Wrapf(err, "unable to start container %s", ctr.ID()) } - if ecode, err := ctr.Wait(); err != nil { + if ecode, err := ctr.Wait(libpod.WaitTimeout); err != nil { logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err) } else { exitCode = int(ecode) diff --git a/cmd/podman/wait.go b/cmd/podman/wait.go index e919ab3ca..48d3885e7 100644 --- a/cmd/podman/wait.go +++ b/cmd/podman/wait.go @@ -3,8 +3,10 @@ package main import ( "fmt" "os" + "time" "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/containers/libpod/libpod" "github.com/pkg/errors" "github.com/urfave/cli" ) @@ -15,7 +17,14 @@ var ( Block until one or more containers stop and then print their exit codes ` - waitFlags = []cli.Flag{LatestFlag} + waitFlags = []cli.Flag{ + cli.UintFlag{ + Name: "interval, i", + Usage: "Milliseconds to wait before polling for completion", + Value: uint(libpod.WaitTimeout), + }, + LatestFlag, + } waitCommand = cli.Command{ Name: "wait", Usage: "Block on one or more containers", @@ -57,7 +66,10 @@ func waitCmd(c *cli.Context) error { if err != nil { return errors.Wrapf(err, "unable to find container %s", container) } - returnCode, err := ctr.Wait() + if c.Uint("interval") == 0 { + return errors.Errorf("interval must be greater then 0") + } + returnCode, err := ctr.Wait(time.Duration(c.Uint("interval"))) if err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) |