docker-compose icon indicating copy to clipboard operation
docker-compose copied to clipboard

Proposal: logs (w/ follow option) provided as logstream method and resolves to {stdout,stderr,process} object

Open jeremygiberson-at-privoro opened this issue 3 years ago • 2 comments

Use case: I'm implementing a wait-for-logs strategy to determine container readiness. I could do polling and repeatedly call logs at some interval, but this is inefficient as I end up re-processing log lines. I would prefer to add a stream data listener and check each log line as it output.

With the current implementation of logs (and the call to execCompose), it doesn't resolve until the process exits (which will be never for long running services like mysql).

I'd like to propose that instead of calling logs with an option to turn on follow and be given an un-resolving promise, we call a logstream method that resolves to an object containing {stdout, stderr, process}. This way we can attach listeners to the streams and potentially close the process when we're done w/ the logs.

Would a PR with this functionality be welcome?

@jeremygiberson-at-privoro This comes up now and then, see #33 and #80. PR will definitely be welcome.

Steveb-p avatar Feb 12 '21 08:02 Steveb-p

@jeremygiberson-at-privoro This would be very useful and the PR is much appreciated.

AlexZeitler avatar Feb 12 '21 18:02 AlexZeitler