chore: add run_check_app
This commit is contained in:
		
							parent
							
								
									97a2bfa891
								
							
						
					
					
						commit
						9f77102f3a
					
				
							
								
								
									
										47
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								src/main.rs
									
									
									
									
									
								
							| @ -24,7 +24,7 @@ use crate::defs::{DataDBs,CollsData,load_cloud_env}; | ||||
| use clds::clouds::defs::{ | ||||
|   Cloud, | ||||
| }; | ||||
| use clds::clouds::on_clouds::{make_cloud_cache,run_clouds_check}; | ||||
| use clds::clouds::on_clouds::{make_cloud_cache,run_clouds_check,run_apps_check}; | ||||
| use reqenv::ReqEnv; | ||||
| 
 | ||||
| // static WEBSERVER: AtomicUsize = AtomicUsize::new(0);
 | ||||
| @ -60,7 +60,7 @@ async fn up_web_server(webpos: usize) -> Result<()> { | ||||
| 		format!("authors: {}",PKG_AUTHORS), | ||||
| 		format!("{}",PKG_DESCRIPTION), | ||||
| 	); | ||||
| 	zterton::init_app(&mut app_env,verbose).await.unwrap_or_else(|e| 
 | ||||
| 	webenv::init_app(&mut app_env,verbose).await.unwrap_or_else(|e| 
 | ||||
| 		panic!("Error loadding app environment {}",e) | ||||
| 	); | ||||
| 	let config = app_env.get_curr_websrvr_config(); | ||||
| @ -78,7 +78,7 @@ async fn up_web_server(webpos: usize) -> Result<()> { | ||||
| 	if verbose > 0 { | ||||
| 		println!("Loading webserver: {} ({})",&config.name,&app_env.curr_web); | ||||
| 	}	
 | ||||
|   let (app, socket) = zterton::start_web(&mut app_env).await; | ||||
|   let (app, socket) = webenv::start_web(&mut app_env).await; | ||||
| 	if verbose > 0 { | ||||
|  	 println!("Load app store ..."); | ||||
| 	} | ||||
| @ -250,14 +250,35 @@ pub async fn run_check_clouds() -> Result<()> { | ||||
| 	let (cloud, app_env) = match get_app_env(arg_cfg_path,verbose).await { | ||||
| 		Ok((c,e)) => (c,e), | ||||
| 		Err(e) => { | ||||
|   	  println!("Check Cloud service: done {} __________ ",&now); | ||||
|   	  println!("Check Cloud services: done {} __________ ",&now); | ||||
| 			return Err(e); | ||||
| 		}, | ||||
| 	}; | ||||
| 	let reqenv = set_reqenv(&app_env,verbose).await; | ||||
| 	let res = run_clouds_check(&reqenv,&cloud).await; | ||||
| 	if verbose > 0 { | ||||
|  	   println!("Check Cloud service: done {} __________ ",&now); | ||||
|  	   println!("Check Cloud services: done {} __________ ",&now); | ||||
| 	} | ||||
| 	res | ||||
| } | ||||
| pub async fn run_check_apps() -> Result<()> { | ||||
| 	let (arg_cfg_path,arg_env_path) = get_args(); | ||||
| 	let now = chrono::Utc::now().timestamp(); | ||||
| 	let verbose = envmnt::get_isize("DEBUG", 0); | ||||
| 	if verbose > 0 { | ||||
|  	  println!("Check Apps services: run {} __________ {} {} ",&now,&arg_cfg_path,&arg_env_path); | ||||
| 	} | ||||
| 	let (cloud, app_env) = match get_app_env(arg_cfg_path,verbose).await { | ||||
| 		Ok((c,e)) => (c,e), | ||||
| 		Err(e) => { | ||||
|   	  println!("Check Apps services: done {} __________ ",&now); | ||||
| 			return Err(e); | ||||
| 		}, | ||||
| 	}; | ||||
| 	let reqenv = set_reqenv(&app_env,verbose).await; | ||||
| 	let res = run_apps_check(&reqenv,&cloud).await; | ||||
| 	if verbose > 0 { | ||||
|  	   println!("Check Apps services: done {} __________ ",&now); | ||||
| 	} | ||||
| 	res | ||||
| } | ||||
| @ -295,12 +316,14 @@ pub async fn main() -> BxDynResult<()> {  //std::io::Result<()> { | ||||
| 	let args: Vec<String> = std::env::args().collect(); | ||||
| 	if args.len() > 1 { | ||||
| 		match args[1].as_str() { | ||||
| 			"-h" | "--help" => 
 | ||||
| 	  		println!("{} USAGE: -c config-toml -e env.file",PKG_NAME), | ||||
| 			"-h" | "--help" => { | ||||
| 	  		println!("{} USAGE: -c config-toml -e env.file",PKG_NAME); | ||||
| 				return Ok(()); | ||||
| 			}, | ||||
| 			"-v" | "--version" => { | ||||
| 	  		println!("{} version: {}",PKG_NAME,PKG_VERSION); | ||||
| 				return Ok(()); | ||||
| 				}, | ||||
| 			}, | ||||
| 			_ => println!("{}",PKG_NAME), | ||||
| 		} | ||||
| 	} | ||||
| @ -338,6 +361,7 @@ pub async fn main() -> BxDynResult<()> {  //std::io::Result<()> { | ||||
| 				"monitor" => tokio::spawn(async {run_clouds_monitor().await}), | ||||
| 				"check" => tokio::spawn(async {run_check_clouds().await}), | ||||
| 				"cache" => tokio::spawn(async {run_cache_clouds().await}), | ||||
| 				"apps" => tokio::spawn(async {run_check_apps().await}), | ||||
| 				_ => { 
 | ||||
| 					eprintln!("Error task {} not defined",&it.name); | ||||
| 					continue; | ||||
| @ -375,6 +399,13 @@ pub async fn main() -> BxDynResult<()> {  //std::io::Result<()> { | ||||
| 						} | ||||
| 						tokio::spawn(async {run_check_clouds().await}); | ||||
| 					})?), | ||||
| 				"apps" => 
 | ||||
| 					sched.add(Job::new(&it.schedule.to_owned(), move |uuid, _l| { | ||||
| 						if debug > 0 { | ||||
| 							println!("Schedule {} {}: {}",&it.name,&it.schedule,uuid); | ||||
| 						} | ||||
| 						tokio::spawn(async {run_check_apps().await}); | ||||
| 					})?), | ||||
| 				"cache" => 
 | ||||
| 					sched.add(Job::new(&it.schedule.to_owned(), move |uuid, _l| { | ||||
| 						if debug > 0 { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user