Skip to content

Commit

Permalink
Merge pull request #23 from radu-matei/fix/shutdown
Browse files Browse the repository at this point in the history
fix(shutdown): handle termination for container
  • Loading branch information
kate-goldenring authored Mar 6, 2024
2 parents b6c0ac0 + 77b383b commit de3d5bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions containerd-shim-spin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ serde_json = "1.0"
url = "2.3"
anyhow = "1.0"
oci-spec = { version = "0.6.3" }
futures = "0.3"
ctrlc = { version = "3.2", features = ["termination"] }

17 changes: 16 additions & 1 deletion containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,22 @@ impl SpinEngine {
}
};
info!(" >>> notifying main thread we are about to start");
f.await
let (abortable, abort_handle) = futures::future::abortable(f);
ctrlc::set_handler(move || abort_handle.abort())?;
match abortable.await {
Ok(Ok(())) => {
info!("Trigger executor shut down: exiting");
Ok(())
}
Ok(Err(err)) => {
log::error!("ERROR >>> Trigger executor failed: {:?}", err);
Err(err)
}
Err(aborted) => {
info!("Received signal to abort: {:?}", aborted);
Ok(())
}
}
}

async fn load_resolved_app_source(
Expand Down

0 comments on commit de3d5bc

Please sign in to comment.