Capture logs from setup script
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user