diff --git a/noxis-rs/src/options/config.rs b/noxis-rs/src/options/config.rs index 54bafce..280e6a4 100644 --- a/noxis-rs/src/options/config.rs +++ b/noxis-rs/src/options/config.rs @@ -9,7 +9,6 @@ use std::sync::Arc; use std::{env, fs}; use super::preboot::PrebootParams; use tokio::time::{Duration, sleep}; -// use redis::PubSub; use tokio::sync::{ oneshot, oneshot::{ Receiver as OneShotReciever, Sender as OneShotSender }, diff --git a/noxis-rs/src/options/structs.rs b/noxis-rs/src/options/structs.rs index 5963b09..034c873 100644 --- a/noxis-rs/src/options/structs.rs +++ b/noxis-rs/src/options/structs.rs @@ -13,7 +13,7 @@ pub mod bus { use noxis_cli::{Cli, metrics_models::MetricsMode}; use crate::utils::metrics::MetricsExportable; - pub type BusMessageContent = Box; + pub type BusMessageContent = Box; #[derive(Debug)] pub enum BusMessage { diff --git a/noxis-rs/src/utils/bus.rs b/noxis-rs/src/utils/bus.rs index b981636..097b0f0 100644 --- a/noxis-rs/src/utils/bus.rs +++ b/noxis-rs/src/utils/bus.rs @@ -19,9 +19,11 @@ impl Highway { Self { to_cli, to_supervisor, to_metrics } } async fn send(&self, msg: BusMessage) -> anyhow::Result<()> { - trace!("redirecting message - {:?} ...", &msg); let dir = match &msg { - BusMessage::Request(dir, ..) | BusMessage::Response(dir, ..) => dir, + BusMessage::Request(dir, ..) | BusMessage::Response(dir, ..) => { + trace!("redirecting message to {:?} ...", dir); + dir + }, }; match dir { BusMessageDirection::ToCli => self.send_cli(msg).await, @@ -58,9 +60,8 @@ impl Bus { impl ProcessUnit for Bus { async fn process(&mut self) { loop { - // TODO while let Ok(content) = self.inner.try_recv() { - debug!("new message to the Bus : {:?}", &content); + // debug!("new message to the Bus : {:?}", &content); let msg = match content { BusMessage::Request(direction, content_type, content) => { trace!("bus has got a new Request with direction {:?} and type {:?}", &direction, &content_type); @@ -75,7 +76,7 @@ impl ProcessUnit for Bus { error!("Cannot redirect message : {}", er); } } - tokio::time::sleep(std::time::Duration::from_millis(100)).await; + tokio::time::sleep(std::time::Duration::from_millis(20)).await; } } } diff --git a/noxis-rs/src/utils/prcs.rs b/noxis-rs/src/utils/prcs.rs index d43c9e7..bf1f1ee 100644 --- a/noxis-rs/src/utils/prcs.rs +++ b/noxis-rs/src/utils/prcs.rs @@ -168,18 +168,32 @@ pub mod v2 { } #[allow(unused)] pub async fn start_by_user_call(&mut self) -> anyhow::Result<()> { - let pid = start_process(&self.name, &self.bin).await?; - warn!("Process {} was started by user call ...", self.name); - self.state = ProcessState::Pending; - self.pid = Pid(pid); - Ok(()) + if self.negative_events.is_empty() { + let pid = start_process(&self.name, &self.bin).await?; + warn!("Process {} was started by user call ...", self.name); + self.state = ProcessState::Pending; + self.pid = Pid(pid); + return Ok(()) + } else { + warn!("Attempt to start process {} by user call was stopped due to existance of negative incidents ...", self.name); + return Err(anyhow::Error::msg( + format!("Attempt to start process {} by user call was stopped due to existance of negative incidents ...", self.name) + )) + } } #[allow(unused)] pub async fn unfreeze_by_user_call(&mut self) -> anyhow::Result<()> { - unfreeze_process(&self.name).await?; - warn!("Process {} was unfrozen by user call ...", self.name); - self.state = ProcessState::Pending; - Ok(()) + if self.negative_events.is_empty() { + unfreeze_process(&self.name).await?; + warn!("Process {} was unfrozen by user call ...", self.name); + self.state = ProcessState::Pending; + Ok(()) + } else { + warn!("Attempt to unfreeze process {} by user call was stopped due to existance of negative incidents ...", self.name); + return Err(anyhow::Error::msg( + format!("Attempt to unfreeze process {} by user call was stopped due to existance of negative incidents ...", self.name) + )) + } } #[allow(unused)] pub async fn restart_by_user_call(&mut self) -> anyhow::Result<()> {