From c174c28bcd12a78ff8a1d695a780eb7de77243c4 Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Sat, 11 Sep 2021 19:27:24 +0100 Subject: [PATCH] chore: monitor cloud config --- app_env/src/config.rs | 61 +++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/app_env/src/config.rs b/app_env/src/config.rs index 91cd0a8..728b790 100644 --- a/app_env/src/config.rs +++ b/app_env/src/config.rs @@ -142,9 +142,16 @@ pub struct Config { pub cache_lock_ext: String, pub run_check: bool, pub check_path: String, + pub run_monitor: bool, + pub monitor_rules_path: String, + pub monitor_rules_file: String, + pub monitor_rules_format: String, + pub monitor_states_path: String, + pub monitor_states_file: String, pub default_lang: String, pub logs_store: String, pub logs_format: String, + pub run_websrvrs: bool, pub websrvrs: Vec, } @@ -172,32 +179,34 @@ impl Config { println!("Config Loaded successfully"); } let app_home=envmnt::get_or("APP_HOME", "."); - // if app_home.is_empty() { - // cfg - // } else { - let mut app_cfg: Config = cfg; - let mut websrvrs: Vec = Vec::new(); - app_cfg.websrvrs.iter().enumerate().for_each(|(pos,it)| { - let app_home_path=format!("{}/{}/",&app_home,&it.home_path); - websrvrs.push(it.to_owned()); - websrvrs[pos].certs_store_path=format!("{}{}",&app_home_path,&it.certs_store_path); - websrvrs[pos].resources_path=format!("{}{}",&app_home_path,&it.resources_path); - websrvrs[pos].templates_path=format!("{}{}",&app_home_path,&it.templates_path); - websrvrs[pos].defaults_path=format!("{}{}",&app_home_path,&it.defaults_path); - websrvrs[pos].html_path=format!("{}{}",&app_home_path,&it.html_path); - websrvrs[pos].dist_path=format!("{}{}",&app_home_path,&it.dist_path); - websrvrs[pos].upload_path=format!("{}{}",&app_home_path,&it.upload_path); - websrvrs[pos].auth_model_path=format!("{}{}",&app_home_path,&it.auth_model_path); - websrvrs[pos].auth_policy_path=format!("{}{}",&app_home_path,&it.auth_policy_path); - websrvrs[pos].usrs_store_target=format!("{}{}",&app_home_path,&it.usrs_store_target); - websrvrs[pos].usrs_shadow_target=format!("{}{}",&app_home_path,&it.usrs_shadow_target); - }); - app_cfg.websrvrs = websrvrs; - app_cfg.cache_path=format!("{}{}",&app_home,&app_cfg.cache_path); - app_cfg.cache_lock_path=format!("{}{}",&app_home,&app_cfg.cache_lock_path); - app_cfg.check_path=format!("{}{}",&app_home,&app_cfg.check_path); - app_cfg - // } + let mut app_cfg: Config = cfg; + + app_cfg.cache_path=format!("{}/{}",&app_home,&app_cfg.cache_path); + app_cfg.cache_lock_path=format!("{}/{}",&app_home,&app_cfg.cache_lock_path); + app_cfg.check_path=format!("{}/{}",&app_home,&app_cfg.check_path); + app_cfg.monitor_rules_path=format!("{}/{}",&app_home,&app_cfg.monitor_rules_path); + app_cfg.monitor_states_path=format!("{}/{}",&app_home,&app_cfg.monitor_states_path); + + let mut websrvrs: Vec = Vec::new(); + + app_cfg.websrvrs.iter().enumerate().for_each(|(pos,it)| { + let app_home_path=format!("{}/{}/",&app_home,&it.home_path); + websrvrs.push(it.to_owned()); + websrvrs[pos].certs_store_path=format!("{}{}",&app_home_path,&it.certs_store_path); + websrvrs[pos].resources_path=format!("{}{}",&app_home_path,&it.resources_path); + websrvrs[pos].templates_path=format!("{}{}",&app_home_path,&it.templates_path); + websrvrs[pos].defaults_path=format!("{}{}",&app_home_path,&it.defaults_path); + websrvrs[pos].html_path=format!("{}{}",&app_home_path,&it.html_path); + websrvrs[pos].dist_path=format!("{}{}",&app_home_path,&it.dist_path); + websrvrs[pos].upload_path=format!("{}{}",&app_home_path,&it.upload_path); + websrvrs[pos].auth_model_path=format!("{}{}",&app_home_path,&it.auth_model_path); + websrvrs[pos].auth_policy_path=format!("{}{}",&app_home_path,&it.auth_policy_path); + websrvrs[pos].usrs_store_target=format!("{}{}",&app_home_path,&it.usrs_store_target); + websrvrs[pos].usrs_shadow_target=format!("{}{}",&app_home_path,&it.usrs_shadow_target); + }); + app_cfg.websrvrs = websrvrs; + + app_cfg }, Err(e) => { println!("Config error: {}",e);