From a6fe8ff24c7fb20cffd298831bbc5e3457aca431 Mon Sep 17 00:00:00 2001 From: rasul Date: Fri, 25 Oct 2019 13:37:17 -0500 Subject: [PATCH] make holds an Option --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index a623d03..edd2690 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,7 +152,7 @@ fn run() -> SupResult<()> { info!("loaded config: sup.toml"); let mut procs: Vec = Vec::new(); - let mut holds: i8 = 0; + let mut holds: Option = None; for app in config.apps() { if app.wait.unwrap_or(false) { @@ -164,7 +164,7 @@ fn run() -> SupResult<()> { match Proc::start(app) { Ok(proc) => { if proc.app.hold.unwrap_or(false) { - holds += 1; + holds = Some(holds.unwrap_or(0) + 1); } procs.push(proc); } @@ -173,12 +173,12 @@ fn run() -> SupResult<()> { } } - if holds < 1 { + if holds.unwrap_or(0) < 1 { error!("no holds configured"); return Ok(()); } - while holds > 0 { + while holds > Some(0) { let mut newprocs: Vec = Vec::new(); while let Some(mut proc) = procs.pop() { @@ -192,12 +192,12 @@ fn run() -> SupResult<()> { Err(e) => { error!("error restarting {}: {:?}", name, e); if hold { - holds -= 1; + holds = Some(holds.unwrap_or(0) - 1); } } }; } else if hold { - holds -= 1; + holds = Some(holds.unwrap_or(0) - 1); } } Ok(None) => {