summaryrefslogtreecommitdiff
path: root/cmd/podman/wait.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-09-10 16:03:52 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2018-09-13 10:11:00 -0400
commit9ec82caa3147d7afaf9361748661c8868194d132 (patch)
tree4de0f051226e638819f2d4e34174b39e4b203c8a /cmd/podman/wait.go
parent61eda671eca96b6fa32369572d9b49850895d37b (diff)
downloadpodman-9ec82caa3147d7afaf9361748661c8868194d132.tar.gz
podman-9ec82caa3147d7afaf9361748661c8868194d132.tar.bz2
podman-9ec82caa3147d7afaf9361748661c8868194d132.zip
Add --interval flag to podman wait
Waiting uses a lot of CPU, so drop back to checking once/second and allow user to pass in the interval. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/wait.go')
-rw-r--r--cmd/podman/wait.go16
1 files changed, 14 insertions, 2 deletions
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)