From 55d38ad7ff1215e58e286dece70c7299e51239d1 Mon Sep 17 00:00:00 2001 From: karthik2804 Date: Wed, 3 Apr 2024 10:10:44 -0700 Subject: [PATCH] allow multi trigger to continue if a trigger exits successfully Signed-off-by: karthik2804 --- src/commands/up.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/commands/up.rs b/src/commands/up.rs index 9fb77a1917..88bf6b0371 100644 --- a/src/commands/up.rs +++ b/src/commands/up.rs @@ -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::>(); @@ -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; } }