fix that processes weren't started until priors finished

This commit is contained in:
2024-07-04 01:41:45 -04:00
parent bab23501ac
commit c504f47e27

View File

@@ -38,7 +38,7 @@ enum MyError {
} }
async fn start(paths: &[impl AsRef<Path>]) -> Result<(), MyError> { async fn start(paths: &[impl AsRef<Path>]) -> Result<(), MyError> {
let handles_and_paths = paths let handles_and_paths: Vec<_> = paths
.into_iter() .into_iter()
.map(|path| { .map(|path| {
let mut command = tokio::process::Command::new("docker"); let mut command = tokio::process::Command::new("docker");
@@ -49,7 +49,8 @@ async fn start(paths: &[impl AsRef<Path>]) -> Result<(), MyError> {
.current_dir(path); .current_dir(path);
(path, command) (path, command)
}) })
.map(|(path, mut command)| (path, tokio::spawn(command.output()))); .map(|(path, mut command)| (path, tokio::spawn(command.output())))
.collect();
for (path, handle) in handles_and_paths { for (path, handle) in handles_and_paths {
let output = handle.await??; let output = handle.await??;
@@ -66,14 +67,15 @@ async fn start(paths: &[impl AsRef<Path>]) -> Result<(), MyError> {
} }
async fn stop(paths: &[impl AsRef<Path>]) -> Result<(), MyError> { async fn stop(paths: &[impl AsRef<Path>]) -> Result<(), MyError> {
let handles_and_paths = paths let handles_and_paths: Vec<_> = paths
.into_iter() .into_iter()
.map(|path| { .map(|path| {
let mut command = tokio::process::Command::new("docker"); let mut command = tokio::process::Command::new("docker");
command.arg("compose").arg("down").current_dir(path); command.arg("compose").arg("down").current_dir(path);
(path, command) (path, command)
}) })
.map(|(path, mut command)| (path, tokio::spawn(command.output()))); .map(|(path, mut command)| (path, tokio::spawn(command.output())))
.collect();
for (path, handle) in handles_and_paths { for (path, handle) in handles_and_paths {
let output = handle.await??; let output = handle.await??;