diff --git a/noxis-rs/src/utils/prcs.rs b/noxis-rs/src/utils/prcs.rs index 7999930..996e46e 100644 --- a/noxis-rs/src/utils/prcs.rs +++ b/noxis-rs/src/utils/prcs.rs @@ -120,7 +120,7 @@ pub mod v2 { match freeze_process(&self.name).await { Ok(_) => { self.state = ProcessState::HoldingByCli; - self.pid = Pid::new(); + // self.pid = Pid::new(); }, Err(er) => { error!("Cannot forcefully freeze process {} : {}", self.name, er); @@ -134,7 +134,7 @@ pub mod v2 { match freeze_process(&self.name).await { Ok(_) => { self.state = ProcessState::Holding; - self.pid = Pid::new(); + // self.pid = Pid::new(); }, Err(er) => { error!("Cannot freeze process {} : {}", self.name, er); @@ -177,6 +177,11 @@ pub mod v2 { self.state = ProcessState::Pending; 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] @@ -190,18 +195,22 @@ pub mod v2 { error!("Cannot unfreeze process {} : {}", self.name, er); } else { self.state = ProcessState::Pending; - self.pid = Pid::new_from_output(get_pid(self.name.as_ref()).await); - info!("{}: New PID - {}", self.name, self.pid); + // self.pid = Pid::new_from_output(get_pid(self.name.as_ref()).await); + // info!("{}: New PID - {}", self.name, self.pid); + info!("Process {} was unfreezed", &self.name); } }, ProcessState::Stopped => { info!("No negative dependecies events on {} process. Starting ...", self.name); - if let Err(er) = start_process(&self.name, &self.bin).await { - error!("Cannot start process {} : {}", self.name, er); - } else { - self.state = ProcessState::Pending; - self.pid = Pid::new_from_output(get_pid(self.name.as_ref()).await); - info!("{}: New PID - {}", self.name, self.pid); + match start_process(&self.name, &self.bin).await { + Ok(pid) => { + self.state = ProcessState::Pending; + self.pid = Pid(pid); + info!("{}: New PID - {}", self.name, self.pid); + }, + Err(er) => { + error!("Cannot start process {} : {}", self.name, er); + }, } }, _ => {},