diff --git a/noxis-rs/src/main.rs b/noxis-rs/src/main.rs index 97d9d8b..616802b 100644 --- a/noxis-rs/src/main.rs +++ b/noxis-rs/src/main.rs @@ -1,6 +1,7 @@ mod options; mod utils; +use anyhow::Error; use clap::Parser; use log::{error, info}; use options::config::*; @@ -17,12 +18,12 @@ use utils::*; use options::preboot::PrebootParams; #[tokio::main(flavor = "multi_thread")] -async fn main() { - let preboot = PrebootParams::parse().validate(); +async fn main() -> anyhow::Result<()>{ + let preboot = PrebootParams::parse().validate()?; - if let Err(_) = preboot { - return; - } + // if let Err(_) = preboot { + // return; + // } let _ = setup_logger(); @@ -32,7 +33,7 @@ async fn main() { // then conf checks to choose the most actual \ let processes: Processes = get_actual_config().await.unwrap_or_else(|| { error!("No actual configuration for runner. Stopping..."); - std::process::exit(101); + std::process::exit(1); }); info!( @@ -43,7 +44,7 @@ async fn main() { if processes.processes.is_empty() { error!("Processes list is null, runner-rs initialization is stopped"); - return; + return Err(Error::msg("Empty processes segment in config")); } let mut handler: Vec> = vec![]; // is in need to send to the signals handler thread @@ -97,7 +98,7 @@ async fn main() { for i in handler { let _ = i.await; } - return; + Ok(()) } // todo: integration tests diff --git a/noxis-rs/src/options/preboot.rs b/noxis-rs/src/options/preboot.rs index 6ecb242..c2241e0 100644 --- a/noxis-rs/src/options/preboot.rs +++ b/noxis-rs/src/options/preboot.rs @@ -104,18 +104,15 @@ pub struct PrebootParams { impl PrebootParams { pub fn validate(self) -> Result { if !self.socket_path.exists() { - eprintln!("Socket-file {} doesn't exist. Cannot start", &self.socket_path.display()); - return Err(Error::msg("Socket-file Not Found")); + return Err(Error::msg("Socket-file not found or Noxis can't read it. Cannot start")); } // existing log dir if !self.log_to.exists() { - eprintln!("Log directory {} doesn't exist", &self.log_to.display()); - return Err(Error::msg("Log Directory Not Found. Cannot start")); + return Err(Error::msg("Log Directory Not Found or Noxis can't read it. Cannot start")); } // existing sock file if !self.config.exists() { - eprintln!("Local config file {} doesn't exist", &self.config.display()); - return Err(Error::msg("Local Config Not Found. Cannot start")); + return Err(Error::msg("Local Config Not Found or Noxis can't read it. Cannot start")); } // redis server check Ok(self)