|
|
|
@ -38,7 +38,7 @@ pub fn run(procs: Vec<Proc>, holds: Option<i8>, poll: Poll) -> Result<Vec<Proc>>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// restart an App, return the new Proc or report error
|
|
|
|
|
fn restart_app(proc: Proc) -> Result<Proc> {
|
|
|
|
|
fn restart_app(proc: &Proc) -> Result<Proc> {
|
|
|
|
|
let app = proc.app.clone();
|
|
|
|
|
let name = proc.app.name.clone();
|
|
|
|
|
|
|
|
|
@ -123,16 +123,30 @@ fn run_loop(procs: Vec<Proc>, holds: Option<i8>, poll: Poll, signals: Signals) -
|
|
|
|
|
}
|
|
|
|
|
// process exited
|
|
|
|
|
Ok(ProcessEvent::Exit(status)) => {
|
|
|
|
|
let hold = proc.app.hold;
|
|
|
|
|
|
|
|
|
|
if let Some(code) = status.code() {
|
|
|
|
|
info!("[{}] exited with code {}", &proc.app.name.yellow(), code);
|
|
|
|
|
if code == 0 {
|
|
|
|
|
info!("[{}] exited successfully", &proc.app.name.yellow());
|
|
|
|
|
|
|
|
|
|
if proc.app.restart_on_failure {
|
|
|
|
|
if let Ok(p) = restart_app(&proc) {
|
|
|
|
|
poll.register(&p.process, p.token, Ready::all(), PollOpt::edge())
|
|
|
|
|
.unwrap();
|
|
|
|
|
procs.push(p);
|
|
|
|
|
} else if hold {
|
|
|
|
|
holds = Some(holds.unwrap_or(0) - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
info!("[{}] exited unsuccessfully with code {}", &proc.app.name.yellow(), code);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
info!("[{}] exited with unknown code", &proc.app.name.yellow());
|
|
|
|
|
info!("[{}] was terminated", &proc.app.name.yellow());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let hold = proc.app.hold.unwrap_or(false);
|
|
|
|
|
|
|
|
|
|
if proc.app.check_restart(status) {
|
|
|
|
|
if let Ok(p) = restart_app(proc) {
|
|
|
|
|
if let Ok(p) = restart_app(&proc) {
|
|
|
|
|
poll.register(&p.process, p.token, Ready::all(), PollOpt::edge())
|
|
|
|
|
.unwrap();
|
|
|
|
|
procs.push(p);
|
|
|
|
|