diff options
author | notgne2 | 2021-01-29 04:13:00 -0700 |
---|---|---|
committer | notgne2 | 2021-02-09 02:55:26 -0700 |
commit | c32d25ec28adafec90c43eb19dc0ecd635f4b746 (patch) | |
tree | 611c4b0e5e1cf532a8ebe6457bd18163eb9de0f0 /src | |
parent | 4ff0e5f90bb297ed73686bc13d4cfe93a5d2e7e8 (diff) |
Use oneshot signals to ensure SSH activate command has finished before deployment ends
Diffstat (limited to 'src')
-rw-r--r-- | src/deploy.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/deploy.rs b/src/deploy.rs index 88becc0..00c97f4 100644 --- a/src/deploy.rs +++ b/src/deploy.rs @@ -246,20 +246,25 @@ pub async fn deploy_profile( ssh_wait_command.arg(ssh_opt); } - tokio::pin! { - let ssh_wait_future = ssh_wait_command.arg(self_wait_command).status(); - let ssh_activate_future = ssh_activate.wait_with_output(); - } + let (send_activate, recv_activate) = tokio::sync::oneshot::channel(); + let (send_activated, recv_activated) = tokio::sync::oneshot::channel(); + + tokio::spawn(async move { + send_activate + .send(ssh_activate.wait_with_output().await) + .unwrap(); + send_activated.send(()).unwrap(); + }); tokio::select! { - x = ssh_wait_future => { + x = ssh_wait_command.arg(self_wait_command).status() => { match x.map_err(DeployProfileError::SSHWaitError)?.code() { Some(0) => (), a => return Err(DeployProfileError::SSHWaitExitError(a)), }; }, - x = ssh_activate_future => { - match x.map_err(DeployProfileError::SSHActivateError)?.status.code() { + x = recv_activate => { + match x.unwrap().map_err(DeployProfileError::SSHActivateError)?.status.code() { Some(0) => (), a => return Err(DeployProfileError::SSHActivateExitError(a)), }; @@ -300,6 +305,8 @@ pub async fn deploy_profile( }; info!("Deployment confirmed."); + + recv_activated.await.unwrap(); } Ok(()) |