pid logic fixed
parent
ac0c3cb8c1
commit
75940cb187
|
|
@ -120,7 +120,7 @@ pub mod v2 {
|
||||||
match freeze_process(&self.name).await {
|
match freeze_process(&self.name).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
self.state = ProcessState::HoldingByCli;
|
self.state = ProcessState::HoldingByCli;
|
||||||
self.pid = Pid::new();
|
// self.pid = Pid::new();
|
||||||
},
|
},
|
||||||
Err(er) => {
|
Err(er) => {
|
||||||
error!("Cannot forcefully freeze process {} : {}", self.name, er);
|
error!("Cannot forcefully freeze process {} : {}", self.name, er);
|
||||||
|
|
@ -134,7 +134,7 @@ pub mod v2 {
|
||||||
match freeze_process(&self.name).await {
|
match freeze_process(&self.name).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
self.state = ProcessState::Holding;
|
self.state = ProcessState::Holding;
|
||||||
self.pid = Pid::new();
|
// self.pid = Pid::new();
|
||||||
},
|
},
|
||||||
Err(er) => {
|
Err(er) => {
|
||||||
error!("Cannot freeze process {} : {}", self.name, er);
|
error!("Cannot freeze process {} : {}", self.name, er);
|
||||||
|
|
@ -177,6 +177,11 @@ pub mod v2 {
|
||||||
self.state = ProcessState::Pending;
|
self.state = ProcessState::Pending;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
pub async fn restart_by_user_call(&mut self) -> anyhow::Result<()> {
|
||||||
|
let pid = restart_process(&self.name, &self.bin).await?;
|
||||||
|
self.pid = Pid(pid);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
@ -190,18 +195,22 @@ pub mod v2 {
|
||||||
error!("Cannot unfreeze process {} : {}", self.name, er);
|
error!("Cannot unfreeze process {} : {}", self.name, er);
|
||||||
} else {
|
} else {
|
||||||
self.state = ProcessState::Pending;
|
self.state = ProcessState::Pending;
|
||||||
self.pid = Pid::new_from_output(get_pid(self.name.as_ref()).await);
|
// self.pid = Pid::new_from_output(get_pid(self.name.as_ref()).await);
|
||||||
info!("{}: New PID - {}", self.name, self.pid);
|
// info!("{}: New PID - {}", self.name, self.pid);
|
||||||
|
info!("Process {} was unfreezed", &self.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ProcessState::Stopped => {
|
ProcessState::Stopped => {
|
||||||
info!("No negative dependecies events on {} process. Starting ...", self.name);
|
info!("No negative dependecies events on {} process. Starting ...", self.name);
|
||||||
if let Err(er) = start_process(&self.name, &self.bin).await {
|
match start_process(&self.name, &self.bin).await {
|
||||||
error!("Cannot start process {} : {}", self.name, er);
|
Ok(pid) => {
|
||||||
} else {
|
|
||||||
self.state = ProcessState::Pending;
|
self.state = ProcessState::Pending;
|
||||||
self.pid = Pid::new_from_output(get_pid(self.name.as_ref()).await);
|
self.pid = Pid(pid);
|
||||||
info!("{}: New PID - {}", self.name, self.pid);
|
info!("{}: New PID - {}", self.name, self.pid);
|
||||||
|
},
|
||||||
|
Err(er) => {
|
||||||
|
error!("Cannot start process {} : {}", self.name, er);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue