Feature Request
I'd like to be able to run a selected process in forground, with stdin\stdout attached, so that I see it's logs and interact with it from command line. All of it's dependent processes should run in the background (no logs output shown in terminal).
This would be similar to docker-compose run $SERVICE_NAME
For example, given the following docker-compose.yaml
:
services:
main:
image: busybox
command:
- sh
- -c
- |
echo running main; while true; read -p "enter some text: " reply && echo $$reply; done
depends_on:
- deps
deps:
image: busybox
command:
- sh
- -c
- while true; do date > deps; sleep 1; done
when I run docker-compose run main
, I see the following:
[+] Running 1/0
⠿ Container example-deps-1 Created 0.0s
[+] Running 1/1
⠿ Container example-deps-1 Started 0.2s
running main
enter some text:
which then allows me to provide input at the prompt
the deps
container keeps running in the background until the main process exits.
Use Case:
I'd like to be able to run tests as the main process and a bunch of deps (databases) as other processes in the background. The main process needs to wait for deps before it starts. I am only interested in seeing the test logs in the terminal, and I'd also like to provide input to the test process while it's running: for example, the jest test runner, when ran in --watch
mode, can be controlled with various keyboard shortcuts which allow to rerun all tests, or only ones that failed.
Proposed Change:
Addition of:
- top level
run
command, taking 1 process name as argument: this would start all process defined in the config file, while attaching to the named process
run
sub-command to the process
command, taking 1 process name as argument: this would start (and attach to) only given process. with all processes in it's dependency tree running in the background
a --no-deps
flag could be nice to have
Who Benefits From The Change(s)?
People who'd like to use PC to interactively run some process, while also running other process on which the main one depends
Alternative Approaches
One could run deps in PC, while the main process outside of it, and use a wrapper script to start\stop PC as needed.
Also, a workaround I am currently using in CI, when running test process and it's deps via PC (with a config similar to this), is a following bash script:
process-compose >/dev/null 2>&1 &
pc_pid=$!
process-compose process logs tests -f &
test_logs_pid=$!
wait $pc_pid
kill $test_logs_pid
This way only output of tests
process is shown in CI logs.
However this would not work if interaction with the tests
process was required, like when running tests via jest --watch
.