X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e7cb79569f8047de64ccec7ec4382bf0f4b7423d..f4a37bb12147851402fd585e6e5987f227591028:/cmd/arvados-client/container_gateway.go diff --git a/cmd/arvados-client/container_gateway.go b/cmd/arvados-client/container_gateway.go index 08f37d5641..7b52cc3a64 100644 --- a/cmd/arvados-client/container_gateway.go +++ b/cmd/arvados-client/container_gateway.go @@ -33,14 +33,15 @@ type logsCommand struct { func (lc logsCommand) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { f := flag.NewFlagSet(prog, flag.ContinueOnError) + follow := f.Bool("f", false, "follow: poll for new data until the container finishes") pollInterval := f.Duration("poll", time.Second*2, "minimum duration to wait before polling for new data") - if ok, code := cmd.ParseFlags(f, prog, args, "container-uuid", stderr); !ok { + if ok, code := cmd.ParseFlags(f, prog, args, "container-request-uuid", stderr); !ok { return code } else if f.NArg() < 1 { - fmt.Fprintf(stderr, "missing required argument: container-uuid (try -help)\n") + fmt.Fprintf(stderr, "missing required argument: container-request-uuid (try -help)\n") return 2 } else if f.NArg() > 1 { - fmt.Fprintf(stderr, "encountered extra arguments after container-uuid (try -help)\n") + fmt.Fprintf(stderr, "encountered extra arguments after container-request-uuid (try -help)\n") return 2 } target := f.Args()[0] @@ -53,7 +54,7 @@ func (lc logsCommand) RunCommand(prog string, args []string, stdin io.Reader, st InsecureSkipVerify: true}} } - err := lc.tailf(target, stdout, stderr, *pollInterval) + err := lc.tail(target, stdout, stderr, *follow, *pollInterval) if err != nil { fmt.Fprintln(stderr, err) return 1 @@ -61,7 +62,7 @@ func (lc logsCommand) RunCommand(prog string, args []string, stdin io.Reader, st return 0 } -func (lc *logsCommand) tailf(crUUID string, stdout, stderr io.Writer, pollInterval time.Duration) error { +func (lc *logsCommand) tail(crUUID string, stdout, stderr io.Writer, follow bool, pollInterval time.Duration) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -157,7 +158,7 @@ poll: displayingUUID = cr.ContainerUUID delay = 0 continue - } else if cr.State == arvados.ContainerRequestStateFinal { + } else if cr.State == arvados.ContainerRequestStateFinal || !follow { break } else if len(newData) > 0 { delay = pollInterval