diff --git a/backend/src/executor.rs b/backend/src/executor.rs index 8506794e..bbc21021 100644 --- a/backend/src/executor.rs +++ b/backend/src/executor.rs @@ -111,7 +111,7 @@ impl ExecutorConfig { } /// Stream output from a child process to the database -async fn stream_output_to_db( +pub async fn stream_output_to_db( output: impl tokio::io::AsyncRead + Unpin, pool: sqlx::SqlitePool, attempt_id: Uuid, diff --git a/backend/src/models/task_attempt.rs b/backend/src/models/task_attempt.rs index ca5ebc3e..cd31262e 100644 --- a/backend/src/models/task_attempt.rs +++ b/backend/src/models/task_attempt.rs @@ -456,7 +456,7 @@ impl TaskAttempt { tracing::info!("Running setup script for task attempt {}", attempt_id); // Start setup script as streaming process - let child = tokio::process::Command::new("bash") + let mut child = tokio::process::Command::new("bash") .arg("-c") .arg(setup_script) .current_dir(&task_attempt.worktree_path) @@ -470,6 +470,35 @@ impl TaskAttempt { ))) })?; + // Stream stdout and stderr to database + if let Some(stdout) = child.stdout.take() { + let pool_clone = pool.clone(); + tokio::spawn(async move { + crate::executor::stream_output_to_db( + stdout, + pool_clone, + attempt_id, + setup_process_id, + true, + ) + .await; + }); + } + + if let Some(stderr) = child.stderr.take() { + let pool_clone = pool.clone(); + tokio::spawn(async move { + crate::executor::stream_output_to_db( + stderr, + pool_clone, + attempt_id, + setup_process_id, + false, + ) + .await; + }); + } + // Add setup script to running executions for monitoring app_state .add_running_execution(