use std::process::Command; use crate::result::Result; #[derive(Clone, Debug, Deserialize)] pub struct App { pub name: String, pub command: String, pub args: Vec, pub restart_on_success: Option, pub restart_on_failure: Option, pub restart_on_terminate: Option, pub wait: Option, pub hold: Option, } impl App { pub fn wait_start(&self) -> Result<()> { info!("starting application {}", &self.name); let mut command = Command::new(&self.command); command.args(&self.args); match command.output() { Ok(output) => { if !output.stdout.is_empty() { let s = String::from_utf8(output.stdout)?; for line in s.lines() { info!("[{}] stdout: {}", &self.name, line); } } if !output.stderr.is_empty() { let s = String::from_utf8(output.stderr)?; for line in s.lines() { info!("[{}] stderr: {}", &self.name, line); } } Ok(()) } Err(e) => Err(Box::from(e)), } } }