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 --exit-with-highest-exit-code and --as-job-runner #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

danieroux
Copy link

@danieroux danieroux commented Oct 18, 2024

--exit-with-highest-exit-code exits hivemind with the highest exit code of all processes, which allows for process failures to bubble up to the shell.

This is different from #30 - this PR does not change current hivemind behaviour.

Closes #27

Example:

$ cat <<PROCFILE > example.procfile
job1: echo "job1 is running"; sleep 0.5; echo "Failing"; exit 13
job2: echo "job2 is running"; sleep 1; echo "Will never complete"; exit 11
PROCFILE
$ hivemind --exit-with-highest-exit-code example.procfile
job2 | Running...
job1 | Running...
job2 | job2 is running
job1 | job1 is running
job1 | Failing
job1 | exit status 13
job2 | Interrupting...
job2 | signal: interrupt
At least one process failed
$ echo "Hivemind exited with: $?"
Hivemind exited with: 13

--as-job-runner changes hivemind from process control to letting jobs run to completion. Example:

$ hivemind --as-job-runner --exit-with-highest-exit-code - <<PROCFILE
job1: echo "job1 is running"; sleep 0.5; echo "Done"
job2: echo "job2 is running"; sleep 1; echo "Done"
PROCFILE
job1 | Running...
job2 | Running...
job2 | job2 is running
job1 | job1 is running
job1 | Done
job1 | Process exited
job2 | Done
job2 | Process exited

$ hivemind  --as-job-runner --exit-with-highest-exit-code - <<PROCFILE
job1: echo "job1 is running"; sleep 0.5; echo "Fail"; exit 13
job2: echo "job2 is running"; sleep 1; echo "Done"
PROCFILE
job2 | Running...
job1 | Running...
job1 | job1 is running
job2 | job2 is running
job1 | Fail
job1 | exit status 13
job2 | Done
job2 | Process exited
At least one process failed

…hest exit code of any processes

This allows for process failures to bubble up to the shell.

Example:

```console
$ hivemind --exit-with-highest-exit-code - <<PROCFILE
job1: echo "job1 is running"; sleep 0.5; echo "Failing"; exit 13
job2: echo "job2 is running"; sleep 1; echo "Will never complete"; exit 11
PROCFILE
job2 | Running...
job1 | Running...
job2 | job2 is running
job1 | job1 is running
job1 | Failing
job1 | exit status 13
job2 | Interrupting...
job2 | signal: interrupt
At least one process failed
$ echo "Hivemind exited with: $?"
Hivemind exited with: 13
```
…t gracefully, and wait for all to complete

See `test-as-job-runner.sh` and:

Example:

```shellsession
hivemind --as-job-runner --exit-with-highest-exit-code - <<PROCFILE
job1: echo "job1 is running"; sleep 0.5; echo "Done"
job2: echo "job2 is running"; sleep 1; echo "Done"
PROCFILE

hivemind --as-job-runner --exit-with-highest-exit-code - <<PROCFILE
job1: echo "job1 is running"; sleep 0.5; echo "Fail"; exit 13
job2: echo "job2 is running"; sleep 1; echo "Done"
PROCFILE
```
@danieroux danieroux changed the title Add --exit-with-highest-exit-code Add --exit-with-highest-exit-code and --as-job-runner Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hivemind process exits 0 regardless of child process status
1 participant