From fea7e969705c62804bd4d532b8b220dc9e3c6fd7 Mon Sep 17 00:00:00 2001 From: rascul Date: Thu, 21 Jul 2022 21:17:08 -0500 Subject: [PATCH] comments --- src/apps.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/apps.rs b/src/apps.rs index 8b1d9f0..298b166 100644 --- a/src/apps.rs +++ b/src/apps.rs @@ -53,31 +53,44 @@ impl Apps { self.apps.clone() } + /// start all the apps pub fn start(&self) -> (Vec, Option, Poll) { + // the managed processes let mut procs: Vec = Vec::new(); + + // number of things to hold on let mut holds: Option = None; + // this should be changed to not unwrap let poll = Poll::new().unwrap(); for app in self.apps() { + // app needs to be waited on before starting the next one if app.wait.unwrap_or(false) { if let Err(e) = app.wait_start() { error!("[{}] failed to start: {:?}", &app.name.yellow(), e); } - } else { + } + // app can go in the background + else { let name = app.name.clone(); + match Proc::start(app) { Ok(proc) => { + // see if we need to hold on this app if proc.app.hold.unwrap_or(false) { holds = Some(holds.unwrap_or(0) + 1); } + + // register the app to poll the status poll.register( &proc.process, proc.token, Ready::readable(), PollOpt::edge(), ) - .unwrap(); + .unwrap(); // gotta get rid of this unwrap + procs.push(proc); } Err(e) => {