[ISSUE#12 "preload errors without returning !!!!"] preload params validation mech fix

pull/19/head
prplV 2024-12-18 10:55:13 +03:00
parent 5a1588e256
commit 1578216712
2 changed files with 12 additions and 5 deletions

View File

@ -52,7 +52,7 @@ pub async fn get_actual_config(params : Arc<PrebootParams>) -> Option<Processes>
// * if no local conf -> loop and +inf getting conf from redis server // * if no local conf -> loop and +inf getting conf from redis server
// * if local conf -> once getting conf from redis server // * if local conf -> once getting conf from redis server
let config_path = params.config.to_str().unwrap_or_else(|| { let config_path = params.config.to_str().unwrap_or_else(|| {
error!("Invalid character in config file. Config path was set as default"); error!("Invalid character in config file. Config path was set to default");
"settings.json" "settings.json"
}); });
info!("Configurating config module with params: no-remote-config={}, no-sub={}, local config path={:?}, remote server={}", params.no_remote_config, params.no_sub, params.config, params.remote_server_url); info!("Configurating config module with params: no-remote-config={}, no-sub={}, local config path={:?}, remote server={}", params.no_remote_config, params.no_sub, params.config, params.remote_server_url);

View File

@ -102,19 +102,26 @@ pub struct PrebootParams {
} }
impl PrebootParams { impl PrebootParams {
pub fn validate(self) -> Result<Self> { pub fn validate(mut self) -> Result<Self> {
if !self.socket_path.exists() && !self.no_hostagent { if !self.socket_path.exists() && !self.no_hostagent {
return Err(Error::msg("Socket-file not found or Noxis can't read it. Cannot start")); eprintln!("Error: Socket-file not found or Noxis can't read it. Socket-file was set to default");
self.socket_path = PathBuf::from("/var/run/enode/hostagent.sock");
// return Err(Error::msg("Socket-file not found or Noxis can't read it. Cannot start"));
} }
// existing log dir // existing log dir
if !self.log_to.exists() && !self.no_logs { if !self.log_to.exists() && !self.no_logs {
return Err(Error::msg("Log Directory Not Found or Noxis can't read it. Cannot start")); eprintln!("Error: LogDir not found or Noxis can't read it. LogDir was set to default");
self.log_to = PathBuf::from("./");
// return Err(Error::msg("Log Directory Not Found or Noxis can't read it. Cannot start"));
} }
// existing sock file // existing sock file
if !self.config.exists() { if !self.config.exists() {
return Err(Error::msg("Local Config Not Found or Noxis can't read it. Cannot start")); eprintln!("Error: Invalid character in config file. Config path was set to default");
self.config = PathBuf::from("settings.json");
// return Err(Error::msg("Local Config Not Found or Noxis can't read it. Cannot start"));
} }
// redis server check // redis server check
dbg!(&self);
Ok(self) Ok(self)
} }
} }