F1bonacc1/process-compose

Add dependency condition for daemon command completed

Closed this issue · 3 comments

Feature Request

There should be an additional condition for process dependency that only applies to daemon processes and corresponds to when the command that starts the daemon finishes. This would allow a config to define dependencies that are much closer to when a daemon actually starts.

Use Case:

In my current config, I have a process A defined which starts a daemon. It takes a few minutes to complete and actually start the daemon. I also have another process B which depends on the daemon running, but as far as I can tell, I can't define a condition to make process B wait until the daemon on A starts. My only option is to use the condition process_started and make sure process B is robust and can keep restarting until process A is running, because process_completed applies to the daemon itself, not to the command that started it.

Proposed Change:

Add an additional condition that corresponds to when the command that spawns a daemon finishes. Optionally add another condition that only completes if the exit status of the command indicates success.

Who Benefits From The Change(s)?

Users with dependencies that involve daemon processes.

Alternative Approaches

Not sure if there's one?

I briefly read the code and it appears that adding most of the code for this should be straightforward. I'm willing to start a PR for this.

As an alternative, you can define a healthcheck command that somehow observes whether the daemon is running (ports opened, lockfile written, etc.) and use process_healthy condition.

Please use the condition: process_healthy.