move shutdown stuff out of startup()

master
rasul 5 years ago
parent ced0ce6286
commit 2b31859e23

@ -14,6 +14,7 @@ mod proc;
mod result; mod result;
use apps::Apps; use apps::Apps;
use proc::Proc;
use result::Result; use result::Result;
fn main() { fn main() {
@ -26,17 +27,25 @@ fn main() {
error!("FATAL: {:?}", e); error!("FATAL: {:?}", e);
std::process::exit(1); std::process::exit(1);
} }
match startup() {
Ok(p) => {
info!("shutting down");
for mut proc in p {
proc.stop();
}
}
Err(e) => {
error!("FATAL: {:?}", e);
std::process::exit(1);
}
};
} }
fn startup() -> Result<()> { fn startup() -> Result<Vec<Proc>> {
let apps = Apps::load("sup.toml")?; let apps = Apps::load("sup.toml")?;
let (procs, holds) = apps.start(); let (procs, holds) = apps.start();
let procs = apps.run(procs, holds)?; let procs = apps.run(procs, holds)?;
info!("shutting down"); Ok(procs)
for mut proc in procs {
proc.stop();
}
Ok(())
} }

Loading…
Cancel
Save