diff --git a/server/src/builder.rs b/server/src/builder.rs index c88e749..839d30d 100644 --- a/server/src/builder.rs +++ b/server/src/builder.rs @@ -45,6 +45,9 @@ pub async fn build_worker(state: AppState) { Some(id) => { if let Err(e) = run_build(&state, &id).await { tracing::error!("Build {} failed: {}", id, e); + // Surface the Rust-level error in the deploy log so it's visible in the UI. + let msg = format!("\n[hiy] FATAL: {}\n", e); + let _ = append_log(&state.db, &id, &msg).await; let _ = set_status(&state.db, &id, "failed").await; } } @@ -97,6 +100,24 @@ async fn run_build(state: &AppState, deploy_id: &str) -> anyhow::Result<()> { let build_dir = format!("{}/builds/{}", state.data_dir, app.id); + // Log diagnostics before spawning so even a spawn failure leaves a breadcrumb. + let cwd = std::env::current_dir() + .map(|p| p.display().to_string()) + .unwrap_or_else(|_| "".into()); + let script_exists = std::path::Path::new(&build_script).exists(); + append_log( + &state.db, + deploy_id, + &format!( + "[hiy] CWD: {}\n\ + [hiy] Build script: {} (exists={})\n\ + [hiy] Build dir: {}\n\ + [hiy] Env file: {}\n---\n", + cwd, build_script, script_exists, build_dir, env_file + ), + ) + .await?; + let mut child = Command::new("bash") .arg(&build_script) .env("APP_ID", &app.id) @@ -109,7 +130,8 @@ async fn run_build(state: &AppState, deploy_id: &str) -> anyhow::Result<()> { .env("BUILD_DIR", &build_dir) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) - .spawn()?; + .spawn() + .map_err(|e| anyhow::anyhow!("Failed to spawn '{}': {}", build_script, e))?; let stdout = child.stdout.take().expect("piped stdout"); let stderr = child.stderr.take().expect("piped stderr");