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 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<WebServer>,
}
@ -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<WebServer> = 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<WebServer> = 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);