chore: monitor cloud config

This commit is contained in:
Jesús Pérez Lorenzo 2021-09-11 19:27:24 +01:00
parent 4998414e68
commit c174c28bcd

View File

@ -142,9 +142,16 @@ pub struct Config {
pub cache_lock_ext: String, pub cache_lock_ext: String,
pub run_check: bool, pub run_check: bool,
pub check_path: String, 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 default_lang: String,
pub logs_store: String, pub logs_store: String,
pub logs_format: String, pub logs_format: String,
pub run_websrvrs: bool,
pub websrvrs: Vec<WebServer>, pub websrvrs: Vec<WebServer>,
} }
@ -172,32 +179,34 @@ impl Config {
println!("Config Loaded successfully"); println!("Config Loaded successfully");
} }
let app_home=envmnt::get_or("APP_HOME", "."); let app_home=envmnt::get_or("APP_HOME", ".");
// if app_home.is_empty() { let mut app_cfg: Config = cfg;
// cfg
// } else { app_cfg.cache_path=format!("{}/{}",&app_home,&app_cfg.cache_path);
let mut app_cfg: Config = cfg; app_cfg.cache_lock_path=format!("{}/{}",&app_home,&app_cfg.cache_lock_path);
let mut websrvrs: Vec<WebServer> = Vec::new(); app_cfg.check_path=format!("{}/{}",&app_home,&app_cfg.check_path);
app_cfg.websrvrs.iter().enumerate().for_each(|(pos,it)| { app_cfg.monitor_rules_path=format!("{}/{}",&app_home,&app_cfg.monitor_rules_path);
let app_home_path=format!("{}/{}/",&app_home,&it.home_path); app_cfg.monitor_states_path=format!("{}/{}",&app_home,&app_cfg.monitor_states_path);
websrvrs.push(it.to_owned());
websrvrs[pos].certs_store_path=format!("{}{}",&app_home_path,&it.certs_store_path); let mut websrvrs: Vec<WebServer> = Vec::new();
websrvrs[pos].resources_path=format!("{}{}",&app_home_path,&it.resources_path);
websrvrs[pos].templates_path=format!("{}{}",&app_home_path,&it.templates_path); app_cfg.websrvrs.iter().enumerate().for_each(|(pos,it)| {
websrvrs[pos].defaults_path=format!("{}{}",&app_home_path,&it.defaults_path); let app_home_path=format!("{}/{}/",&app_home,&it.home_path);
websrvrs[pos].html_path=format!("{}{}",&app_home_path,&it.html_path); websrvrs.push(it.to_owned());
websrvrs[pos].dist_path=format!("{}{}",&app_home_path,&it.dist_path); websrvrs[pos].certs_store_path=format!("{}{}",&app_home_path,&it.certs_store_path);
websrvrs[pos].upload_path=format!("{}{}",&app_home_path,&it.upload_path); websrvrs[pos].resources_path=format!("{}{}",&app_home_path,&it.resources_path);
websrvrs[pos].auth_model_path=format!("{}{}",&app_home_path,&it.auth_model_path); websrvrs[pos].templates_path=format!("{}{}",&app_home_path,&it.templates_path);
websrvrs[pos].auth_policy_path=format!("{}{}",&app_home_path,&it.auth_policy_path); websrvrs[pos].defaults_path=format!("{}{}",&app_home_path,&it.defaults_path);
websrvrs[pos].usrs_store_target=format!("{}{}",&app_home_path,&it.usrs_store_target); websrvrs[pos].html_path=format!("{}{}",&app_home_path,&it.html_path);
websrvrs[pos].usrs_shadow_target=format!("{}{}",&app_home_path,&it.usrs_shadow_target); websrvrs[pos].dist_path=format!("{}{}",&app_home_path,&it.dist_path);
}); websrvrs[pos].upload_path=format!("{}{}",&app_home_path,&it.upload_path);
app_cfg.websrvrs = websrvrs; websrvrs[pos].auth_model_path=format!("{}{}",&app_home_path,&it.auth_model_path);
app_cfg.cache_path=format!("{}{}",&app_home,&app_cfg.cache_path); websrvrs[pos].auth_policy_path=format!("{}{}",&app_home_path,&it.auth_policy_path);
app_cfg.cache_lock_path=format!("{}{}",&app_home,&app_cfg.cache_lock_path); websrvrs[pos].usrs_store_target=format!("{}{}",&app_home_path,&it.usrs_store_target);
app_cfg.check_path=format!("{}{}",&app_home,&app_cfg.check_path); websrvrs[pos].usrs_shadow_target=format!("{}{}",&app_home_path,&it.usrs_shadow_target);
app_cfg });
// } app_cfg.websrvrs = websrvrs;
app_cfg
}, },
Err(e) => { Err(e) => {
println!("Config error: {}",e); println!("Config error: {}",e);