|
|
@ -19,13 +19,16 @@ pub struct App {
|
|
|
|
pub args: Option<Vec<String>>,
|
|
|
|
pub args: Option<Vec<String>>,
|
|
|
|
|
|
|
|
|
|
|
|
/// should the app be restarted if it exits successfully
|
|
|
|
/// should the app be restarted if it exits successfully
|
|
|
|
pub restart_on_success: Option<bool>,
|
|
|
|
#[serde(default = "ret_false")]
|
|
|
|
|
|
|
|
pub restart_on_success: bool,
|
|
|
|
|
|
|
|
|
|
|
|
/// should the app be restarted if it exits unsuccessfully
|
|
|
|
/// should the app be restarted if it exits unsuccessfully
|
|
|
|
pub restart_on_failure: Option<bool>,
|
|
|
|
#[serde(default = "ret_false")]
|
|
|
|
|
|
|
|
pub restart_on_failure: bool,
|
|
|
|
|
|
|
|
|
|
|
|
/// should the app be restarted if it is killed (SIGKILL)
|
|
|
|
/// should the app be restarted if it is killed (SIGKILL)
|
|
|
|
pub restart_on_terminate: Option<bool>,
|
|
|
|
#[serde(default = "ret_false")]
|
|
|
|
|
|
|
|
pub restart_on_terminate: bool,
|
|
|
|
|
|
|
|
|
|
|
|
/// on sup startup, should we wait for this app to run before continuting
|
|
|
|
/// on sup startup, should we wait for this app to run before continuting
|
|
|
|
pub wait: Option<bool>,
|
|
|
|
pub wait: Option<bool>,
|
|
|
@ -34,6 +37,10 @@ pub struct App {
|
|
|
|
pub hold: Option<bool>,
|
|
|
|
pub hold: Option<bool>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn ret_false() -> bool {
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl App {
|
|
|
|
impl App {
|
|
|
|
/// start the application and wait for it to exit
|
|
|
|
/// start the application and wait for it to exit
|
|
|
|
pub fn wait_start(&self) -> Result<()> {
|
|
|
|
pub fn wait_start(&self) -> Result<()> {
|
|
|
@ -66,11 +73,11 @@ impl App {
|
|
|
|
/// see if the app should be restarted
|
|
|
|
/// see if the app should be restarted
|
|
|
|
pub fn check_restart(&self, status: ExitStatus) -> bool {
|
|
|
|
pub fn check_restart(&self, status: ExitStatus) -> bool {
|
|
|
|
if status.success() {
|
|
|
|
if status.success() {
|
|
|
|
self.restart_on_success.unwrap_or(false)
|
|
|
|
self.restart_on_success
|
|
|
|
} else if let Some(_code) = status.code() {
|
|
|
|
} else if let Some(_code) = status.code() {
|
|
|
|
self.restart_on_failure.unwrap_or(false)
|
|
|
|
self.restart_on_failure
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
self.restart_on_terminate.unwrap_or(false)
|
|
|
|
self.restart_on_terminate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|