From e29140657a77ff4cf3051b720d3a3f88c608236f Mon Sep 17 00:00:00 2001 From: prplV Date: Thu, 4 Jul 2024 09:46:45 -0400 Subject: [PATCH] useless loops are died but BUG is still here --- src/main.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6313b55..e029734 100644 --- a/src/main.rs +++ b/src/main.rs @@ -262,7 +262,6 @@ async fn start_process(name: &str, path: &str) -> Result<(), CustomError> { } // check process status daemon async fn running_handler(name: &str, path: &str, tx: mpsc::Sender){ - loop { // println!("running daemon on {}", name); let _ = Command::new("pidof") .arg(name) @@ -278,14 +277,11 @@ async fn running_handler(name: &str, path: &str, tx: mpsc::Sender){ } } tokio::time::sleep(Duration::from_millis(100)).await; - } } async fn file_handler(name: &str, files: &Vec, tx: mpsc::Sender) { - loop { // println!("file daemon on {}", name); if is_active(name) { - let mut er = 0; for file in files { match check_file(&file.filename, &file.src) { Ok(_) => { @@ -297,12 +293,10 @@ async fn file_handler(name: &str, files: &Vec, tx: mpsc::Sender) { continue; }, "stop" => { - er += 1; tx.send(1).await.unwrap(); - break; + return; }, "hold" => { - er += 1; tx.send(2).await.unwrap(); break; }, @@ -314,12 +308,11 @@ async fn file_handler(name: &str, files: &Vec, tx: mpsc::Sender) { }, } } - if is_frozen(name) && er == 0 { + if is_frozen(name) { tx.send(10).await.unwrap(); } } tokio::time::sleep(Duration::from_millis(100)).await; - } } fn check_file(filename: &str, path: &str) -> Result<(), CustomError> { let fileconcat = format!("{}{}", path, filename); @@ -333,7 +326,6 @@ fn check_file(filename: &str, path: &str) -> Result<(), CustomError> { // ?? async fn service_handler(name: &str, services: &Vec, tx: mpsc::Sender) { - loop { // println!("service daemon on {}", name); if is_active(name) { let mut er = 0; @@ -385,7 +377,6 @@ async fn service_handler(name: &str, services: &Vec, tx: mpsc::Sender< } } tokio::time::sleep(Duration::from_millis(100)).await; - } } async fn looped_service_connecting(