Skip to content

Commit

Permalink
Pipe custom node stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
haixuanTao committed Apr 25, 2023
1 parent be2c45e commit d9172ef
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions binaries/daemon/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ pub async fn spawn_node(
command.env(key, value.to_string());
}
}
command.spawn().wrap_err_with(move || {
command
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn().wrap_err_with(move || {
format!(
"failed to run `{}` with args `{}`",
n.source,
Expand Down Expand Up @@ -131,7 +135,6 @@ pub async fn spawn_node(
eyre::bail!("Runtime can not mix Python Operator with other type of operator.");
};
command.current_dir(working_dir);
command.stdin(Stdio::null());

let runtime_config = RuntimeConfig {
node: NodeConfig {
Expand Down Expand Up @@ -178,7 +181,6 @@ pub async fn spawn_node(
)
.await
.expect("Failed to create log file");

let mut stdout_lines =
(tokio::io::BufReader::new(child.stdout.take().expect("failed to take stdout"))).lines();

Expand Down Expand Up @@ -230,7 +232,7 @@ pub async fn spawn_node(
file.write_all(b"\n")
.await
.expect("Could not add newline to log file.");
debug!("{dataflow_id}/{node_id} logged {line}");
debug!("{dataflow_id}/{} logged {line}", node.id.clone());

// Make sure that all data has been synced to disk.
file.sync_all().await.unwrap();
Expand Down

0 comments on commit d9172ef

Please sign in to comment.