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

(Discussion): allow multi trigger to continue if a trigger exits successfully #2419

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/commands/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl UpCommand {

set_kill_on_ctrl_c(&pids)?;

let trigger_tasks = trigger_processes
let mut trigger_tasks = trigger_processes
.into_iter()
.map(|mut ch| tokio::task::spawn(async move { ch.wait().await }))
.collect::<Vec<_>>();
Expand All @@ -219,16 +219,24 @@ impl UpCommand {
tokio::time::sleep(MULTI_TRIGGER_LET_ALL_START).await;
}

let (first_to_finish, _index, _rest) = futures::future::select_all(trigger_tasks).await;
loop {
let (first_to_finish, _index, rest) = futures::future::select_all(trigger_tasks).await;

if let Ok(process_result) = first_to_finish {
let status = process_result?;
if !status.success() {
if is_multi {
println!("A trigger exited unexpectedly. Terminating.");
kill_child_processes(&pids);
if let Ok(process_result) = first_to_finish {
let status = process_result?;
if !status.success() {
if is_multi {
println!("A trigger exited unexpectedly. Terminating.");
kill_child_processes(&pids);
}
return Err(crate::subprocess::ExitStatusError::new(status).into());
}
return Err(crate::subprocess::ExitStatusError::new(status).into());
}

if rest.is_empty() {
break;
} else {
trigger_tasks = rest;
}
}

Expand Down
Loading