Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show logs of spin module #168

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading