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,11 +179,16 @@ 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() {
// cfg
// } else {
let mut app_cfg: Config = 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(); let mut websrvrs: Vec<WebServer> = Vec::new();
app_cfg.websrvrs.iter().enumerate().for_each(|(pos,it)| { app_cfg.websrvrs.iter().enumerate().for_each(|(pos,it)| {
let app_home_path=format!("{}/{}/",&app_home,&it.home_path); let app_home_path=format!("{}/{}/",&app_home,&it.home_path);
websrvrs.push(it.to_owned()); websrvrs.push(it.to_owned());
@ -193,11 +205,8 @@ impl Config {
websrvrs[pos].usrs_shadow_target=format!("{}{}",&app_home_path,&it.usrs_shadow_target); websrvrs[pos].usrs_shadow_target=format!("{}{}",&app_home_path,&it.usrs_shadow_target);
}); });
app_cfg.websrvrs = websrvrs; 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 app_cfg
// }
}, },
Err(e) => { Err(e) => {
println!("Config error: {}",e); println!("Config error: {}",e);