chore: trace monitor info with debug

This commit is contained in:
Jesús Pérez Lorenzo 2021-10-20 11:14:30 +01:00
parent f694a9c510
commit d19212c026

View File

@ -10,15 +10,24 @@ use crate::clouds::defs::{
};
pub async fn get_cloud_monitor_info(cloud: &mut Cloud, source: &str) -> Result<String> {
let debug = envmnt::get_isize("DEBUG",0);
let cloud_home_path = format!("{}/{}",&cloud.env.home,&source);
let monitor_path = format!("{}/{}",&cloud_home_path,&cloud.env.monitor_run);
if debug > 1 {
println!("home_path: {}",&monitor_path);
println!("monitor_path: {}",&monitor_path);
}
if Path::new(&monitor_path).exists() {
let output = Command::new("bash")
.arg(format!("{}",&monitor_path))
// let output = Command::new("bash")
// .arg(format!("{}",&monitor_path))
let output = Command::new(&monitor_path)
.arg("-o")
.arg("json")
.arg(format!("{}",&source))
.output()?;
if debug > 2 {
dbg!(&output);
}
if !&output.status.success() {
return Err(anyhow!("Run {} for {} failed: {}",&cloud.env.monitor_run,&source,&output.status));
}