Skip to content

Commit

Permalink
cargo-shuttle: clarified logging in case runtime stopping errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianbarbu committed Apr 26, 2023
1 parent 281d5d5 commit 3bf6a0d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ impl Shuttle {
.stop(tonic::Request::new(stop_request))
.or_else(|err| async {
runtime.kill().await?;
error!(status = ?err, "killed the runtime by force because stopping it errored out");
Err(err)
})
.await?
Expand All @@ -681,18 +682,17 @@ impl Shuttle {
None => {
provisioner_server.abort();
for rt_info in existing_runtimes {
let mut killed_by_error = false;
let mut errored_out = false;
// Stopping all runtimes gracefully first, but if this errors out the function kills the runtime forcefully.
Shuttle::stop_runtime(&mut rt_info.0, &mut rt_info.1)
.await
.unwrap_or_else(|err| {
info!(status = ?err, "stopping the runtime errored out");
killed_by_error = true;
.unwrap_or_else(|_| {
errored_out = true;
});

// If the runtime stopping is successful, we still need to kill it forcefully because we exit outside the loop
// and destructors will not be guaranteed to run.
if !killed_by_error {
if !errored_out {
rt_info.0.kill().await?;
}
}
Expand Down

0 comments on commit 3bf6a0d

Please sign in to comment.