master
rascul 2 years ago
parent 26ec5d25e8
commit fea7e96970

@ -53,31 +53,44 @@ impl Apps {
self.apps.clone() self.apps.clone()
} }
/// start all the apps
pub fn start(&self) -> (Vec<Proc>, Option<i8>, Poll) { pub fn start(&self) -> (Vec<Proc>, Option<i8>, Poll) {
// the managed processes
let mut procs: Vec<Proc> = Vec::new(); let mut procs: Vec<Proc> = Vec::new();
// number of things to hold on
let mut holds: Option<i8> = None; let mut holds: Option<i8> = None;
// this should be changed to not unwrap
let poll = Poll::new().unwrap(); let poll = Poll::new().unwrap();
for app in self.apps() { for app in self.apps() {
// app needs to be waited on before starting the next one
if app.wait.unwrap_or(false) { if app.wait.unwrap_or(false) {
if let Err(e) = app.wait_start() { if let Err(e) = app.wait_start() {
error!("[{}] failed to start: {:?}", &app.name.yellow(), e); error!("[{}] failed to start: {:?}", &app.name.yellow(), e);
} }
} else { }
// app can go in the background
else {
let name = app.name.clone(); let name = app.name.clone();
match Proc::start(app) { match Proc::start(app) {
Ok(proc) => { Ok(proc) => {
// see if we need to hold on this app
if proc.app.hold.unwrap_or(false) { if proc.app.hold.unwrap_or(false) {
holds = Some(holds.unwrap_or(0) + 1); holds = Some(holds.unwrap_or(0) + 1);
} }
// register the app to poll the status
poll.register( poll.register(
&proc.process, &proc.process,
proc.token, proc.token,
Ready::readable(), Ready::readable(),
PollOpt::edge(), PollOpt::edge(),
) )
.unwrap(); .unwrap(); // gotta get rid of this unwrap
procs.push(proc); procs.push(proc);
} }
Err(e) => { Err(e) => {

Loading…
Cancel
Save