Skip to content

Commit

Permalink
fix: show logs of spin module
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Pfennig <[email protected]>
  • Loading branch information
0xE282B0 committed Oct 16, 2023
1 parent c96f4b5 commit 46b51db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions containerd-shim-spin-v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
19 changes: 18 additions & 1 deletion containerd-shim-spin-v1/src/engine.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -102,7 +119,7 @@ impl Engine for SpinEngine {
}

fn run_wasi(&self, _ctx: &impl RuntimeContext, stdio: Stdio) -> Result<i32> {
log::info!("setting up wasi");
info!("setting up wasi");
stdio.redirect()?;
let rt = Runtime::new().context("failed to create runtime")?;

Expand Down

0 comments on commit 46b51db

Please sign in to comment.