diff --git a/containerd-shim-spin-v1/Cargo.toml b/containerd-shim-spin-v1/Cargo.toml index 1e5687de..a3907ed9 100644 --- a/containerd-shim-spin-v1/Cargo.toml +++ b/containerd-shim-spin-v1/Cargo.toml @@ -14,6 +14,8 @@ Containerd shim for running Spin workloads. containerd-shim = "0.5.0" containerd-shim-wasm = { git = "https://github.com/containerd/runwasi", rev = "4d212b968d24d42a27952e8b04979382b543a613", features = ["cgroupsv2"] } log = "0.4" +spin-app = { git = "https://github.com/fermyon/spin", tag = "v1.5.0" } +spin-core = { git = "https://github.com/fermyon/spin", tag = "v1.5.0" } spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v1.5.0" } spin-trigger-http = { git = "https://github.com/fermyon/spin", tag = "v1.5.0" } spin-redis-engine = { git = "https://github.com/fermyon/spin", tag = "v1.5.0" } diff --git a/containerd-shim-spin-v1/src/engine.rs b/containerd-shim-spin-v1/src/engine.rs index c807a435..6890dcd1 100644 --- a/containerd-shim-spin-v1/src/engine.rs +++ b/containerd-shim-spin-v1/src/engine.rs @@ -1,4 +1,5 @@ use anyhow::{anyhow, Context, Result}; +use spin_trigger::TriggerHooks; use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::path::PathBuf; @@ -17,6 +18,22 @@ const SPIN_ADDR: &str = "0.0.0.0:80"; #[derive(Clone, Default)] pub struct SpinEngine; +struct StdioTriggerHook{} +impl TriggerHooks for StdioTriggerHook { + fn app_loaded(&mut self, _app: &spin_app::App, _runtime_config: &RuntimeConfig) -> Result<()> { + Ok(()) + } + + fn component_store_builder( + &self, + _component: &spin_app::AppComponent, + builder: &mut spin_core::StoreBuilder, + ) -> Result<()> { + builder.inherit_stdout(); + builder.inherit_stderr(); + Ok(()) + } +} impl SpinEngine { async fn build_spin_application( @@ -102,7 +119,7 @@ impl Engine for SpinEngine { } fn run_wasi(&self, _ctx: &impl RuntimeContext, stdio: Stdio) -> Result { - log::info!("setting up wasi"); + info!("setting up wasi"); stdio.redirect()?; let rt = Runtime::new().context("failed to create runtime")?;