Skip to content

On-the-fly streaming access to a Process's outputs #11056

@stuhood

Description

@stuhood

It would be useful to be able to view the output of any currently running process without needing to toggle to a different mode in order to have it rendered, or to expect that @rules had been authored a particular way.

We currently have a facility for guaranteeing that the output of a process is streamed (InteractiveProcess), but due to the (intended) limitations of InteractiveProcess this is a static decision at @rule authoring time, which inhibits concurrency. There is also a draft of allowing any Process to toggle streaming output (which would also inhibit concurrency for now: see #8974), but that would still require that you knew that you wanted the outputs to be streamed before you started running a command.

In Pants v1, ./pants server provided a way to follow the stdout/stderr of a process. Reviving a very small portion of that facility in one way or another would allow someone to "attach" to a running Process to receive streaming stdout/stderr for it.

There are at least two potential implementations for this:

  1. Have pantsd open an http port on localhost, and render tiny per-Process URLs in logs:

    # template:
    http://localhost:${random_port}/${abbreviated_digest}
    # in the log:
    My Process [http://localhost:1234/e3b0c44298]
    

    In supported terminals (although there are not many, unfortunately) it's also possible to render these directly as links, which would make them much less obtrusive.

  2. Render a tiny uniquely identifying slug for any Process, and provide a (native/intrinsic) pants goal for introspecting the Process:

    # in the log:
    My Process [e3b0c44298]
    # native goal for introspection:
    ./pants process --stdout -- e3b0c44298
    

The former is very discoverable, but potentially noisy since most terminals do not support hyperlinks. The latter doesn't require HTTP (or any HTML landing pages), but is probably less discoverable. A middle ground might be to assume hyperlink support in the terminal and render a slug, but document how to use the hashes if your terminal does not have hyperlink support (ie, explain how to construct the URL manually given a slug).


From an implementation perspective: the local process runner supports streaming output of processes, and there is an extension for output streaming for remote execution. So we would mostly just need a way to rendezvous an incoming HTTP or native-goal request for a running process slug with the ongoing Process.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions