diff --git a/src/main.rs b/src/main.rs index 3007fbd..abea9d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -146,15 +146,11 @@ fn main() { } } -#[allow(clippy::cognitive_complexity)] -fn run() -> SupResult<()> { - let config = Config::load("sup.toml")?; - info!("loaded config: sup.toml"); - +fn start_apps(apps: Vec) -> (Vec, Option) { let mut procs: Vec = Vec::new(); let mut holds: Option = None; - for app in config.apps() { + for app in apps { if app.wait.unwrap_or(false) { if let Err(e) = app.wait_start() { error!("app failed to start: {}: {:?}", &app.name, e); @@ -168,11 +164,20 @@ fn run() -> SupResult<()> { } procs.push(proc); } - Err(e) => error!("application failed to start: {}: {:?}", name, e), + Err(e) => error!("app failed to start: {}: {:?}", name, e), }; } } + (procs, holds) +} + +fn run() -> SupResult<()> { + let config = Config::load("sup.toml")?; + info!("loaded config: sup.toml"); + + let (mut procs, mut holds) = start_apps(config.apps()); + if holds.unwrap_or(0) < 1 { error!("no holds configured"); return Ok(());