From 02c34b30fd106a484be5109f70e06eba6bf8249b Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Fri, 27 Nov 2020 21:26:21 -0800 Subject: [PATCH] Allow the local-orchestrator to stream agent output into the logs This is now the third place I have this same exact code. This should be refactored into an otto-exec crate and re-used between `sh`, `otto-agent`, and the local orchestrator --- Cargo.lock | 1 + services/local-orchestrator/Cargo.toml | 1 + services/local-orchestrator/src/main.rs | 27 +++++++++++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66adabc..26a8030 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1618,6 +1618,7 @@ version = "0.1.0" dependencies = [ "async-std", "log", + "os_pipe", "otto-agent", "otto-models", "pretty_env_logger 0.4.0", diff --git a/services/local-orchestrator/Cargo.toml b/services/local-orchestrator/Cargo.toml index 52cea21..ebd5d68 100644 --- a/services/local-orchestrator/Cargo.toml +++ b/services/local-orchestrator/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] async-std = { version = "~1.7", features = ["attributes"]} log = "~0.4.11" +os_pipe = "~0.9.2" otto-agent = { path = "../../crates/agent" } otto-models = { path = "../../crates/models" } pretty_env_logger = "~0.4.0" diff --git a/services/local-orchestrator/src/main.rs b/services/local-orchestrator/src/main.rs index 2d0ee0b..8fdcc08 100644 --- a/services/local-orchestrator/src/main.rs +++ b/services/local-orchestrator/src/main.rs @@ -19,6 +19,8 @@ struct RunWorkload { * */ fn run_context(pipeline: &Uuid, ctx: &otto_models::Context) -> std::io::Result { + use os_pipe::pipe; + use std::io::{BufRead, BufReader}; use std::io::{Error, ErrorKind}; use std::process::Command; use tempfile::NamedTempFile; @@ -39,17 +41,26 @@ fn run_context(pipeline: &Uuid, ctx: &otto_models::Context) -> std::io::Result) -> tide::Result {