separate app shutdown

master
rasul 5 years ago
parent a16c444025
commit 41a2abac3f

@ -49,13 +49,13 @@ impl Apps {
(procs, holds)
}
pub fn run(&self, procs: Vec<Proc>, holds: Option<i8>) -> Result<()> {
pub fn run(&self, procs: Vec<Proc>, holds: Option<i8>) -> Result<Vec<Proc>> {
let mut procs = procs;
let mut holds = holds;
if holds.unwrap_or(0) < 1 {
error!("no holds configured");
return Ok(());
return Ok(Vec::new());
}
while holds > Some(0) {
@ -99,12 +99,6 @@ impl Apps {
procs = newprocs;
}
info!("shutting down");
for mut proc in procs {
info!("stopping {}", &proc.app.name);
let _ = proc.child.kill();
}
Ok(())
Ok(procs)
}
}

@ -31,6 +31,12 @@ fn main() {
fn startup() -> Result<()> {
let apps = Apps::load("sup.toml")?;
let (procs, holds) = apps.start();
apps.run(procs, holds)?;
let procs = apps.run(procs, holds)?;
info!("shutting down");
for mut proc in procs {
proc.stop();
}
Ok(())
}

@ -23,6 +23,11 @@ impl Proc {
Ok(Proc { app, child })
}
pub fn stop(&mut self) {
info!("stopping {}", &self.app.name);
let _ = self.child.kill();
}
pub fn check_stdout(&mut self) -> Option<String> {
let child_stdout = self.child.stdout.as_mut();
if let Some(stdout) = child_stdout {

Loading…
Cancel
Save