make holds an Option<i8>

master
rasul 5 years ago
parent 132bc6311f
commit a6fe8ff24c

@ -152,7 +152,7 @@ fn run() -> SupResult<()> {
info!("loaded config: sup.toml");
let mut procs: Vec<Proc> = Vec::new();
let mut holds: i8 = 0;
let mut holds: Option<i8> = 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<Proc> = 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) => {

Loading…
Cancel
Save