Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --detach option for the up command to launch processes in the background #169

Closed
jgoux opened this issue Mar 27, 2024 · 5 comments
Closed
Labels
done Done, awaiting release enhancement New feature or request

Comments

@jgoux
Copy link

jgoux commented Mar 27, 2024

Hello 👋,

Feature Request

I'd like to be able to launch process-compose up in the background, without any logs being printed to the current terminal.

Use Case:

I'm interested in this feature in the context of CI. I'm using devenv to bootstrap my infrastructure, and devenv now relies on process-compose to handle multiple services (for example PostgreSQL).

I read that sending processes in the background was doable since v1.0.0 but it needs to be done within the terminal UI. In my case I don't want to interact with the terminal UI at all.

Proposed Change:

Add a --detach / -d option to process-compose up to send it to the background.

It would be similar to docker-compose up --detach: https://docs.docker.com/reference/cli/docker/compose/up/

Who Benefits From The Change(s)?

I guess everyone who launches process-compose in a non-interactive environment?

Alternative Approaches

@VanCoding
Copy link

What would be needed for this? Here's what I guess should happen when the "--detach" option is set:

  • ensure that the httpServer is enabled, fail otherwise
  • start another, detached process with the same args, without the TUI
  • exit with code 0 (but let the detached process continue to run)

But I think that doesn't make much sense, if there's no option to tell the "parent" process to wait until a specified list of processes become healthy. Therefore I suggest to also add an option "--wait-until-healthy [process-name]", which can be provided multiple times for every process that should be healthy before exiting.

Then, if the detached process exits before these processes become healthy, the parent-process errors and exits with a non-zero code. Otherhise, if all the processes become healthy, the parent process exits with code 0.

@KDanisme
Copy link

In my case I settled with launching process-compose in the background with the http server and waiting until a conditan is met.

wait-until process-compose process list --port 5000 -o json | jq '.[] |= .is_ready == \"Ready\" or .status == \"Completed\" | all'"

This handles cases where there are long running and dependent processes alike which i need to wait for.

wait-until is a simple bash script which runs the command until it succeeds, with a timeout

@F1bonacc1 F1bonacc1 added the done Done, awaiting release label Aug 15, 2024
F1bonacc1 added a commit that referenced this issue Aug 17, 2024
@F1bonacc1
Copy link
Owner

Thank you for your patience! 🙏🏻
Added in v1.24.0

@VanCoding
Copy link

@F1bonacc1 Thanks! :) I'll try to integrate it into https://github.com/Platonic-Systems/process-compose-flake

@adamcstephens
Copy link

This is in fact now added to process-compose-flake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Done, awaiting release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants