From c5a3c470ac49d55450c7722fd768ea189fdd7655 Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Tue, 7 Sep 2021 10:05:12 +0100 Subject: [PATCH] chore: pretty_env_logger, new web_rt.block_on out of monitor loop --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 505c0c8..d2ad71b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -310,6 +310,7 @@ pub fn main() -> Result<()> { let env_path = std::path::Path::new(&arg_env_path); dotenv::from_path(env_path)?; } + pretty_env_logger::init(); // assert!(output.is_ok()); let loop_duration: u64; let run_cache: bool; @@ -338,9 +339,16 @@ pub fn main() -> Result<()> { let rt = tokio::runtime::Runtime::new().unwrap_or_else(|e| panic!("Error create tokio runtime {}",e) ); + let webs_rt = tokio::runtime::Runtime::new().unwrap_or_else(|e| + panic!("Error create webs tokio runtime {}",e) + ); + let mut web_tasks = Vec::new(); + webs_rt.block_on(async move { + web_tasks.push(tokio::spawn(async move {up_web_server().await })); + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; + }); loop { rt.block_on(async move { - tokio::spawn(async move {up_web_server().await }); tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; if run_check { tokio::spawn(async {run_check_clouds().await }); // For async task