useless loops are died but BUG is still here

pull/9/head
prplV 2024-07-04 09:46:45 -04:00
parent f0fe76aa1f
commit e29140657a
1 changed files with 2 additions and 11 deletions

View File

@ -262,7 +262,6 @@ async fn start_process(name: &str, path: &str) -> Result<(), CustomError> {
} }
// check process status daemon // check process status daemon
async fn running_handler(name: &str, path: &str, tx: mpsc::Sender<u8>){ async fn running_handler(name: &str, path: &str, tx: mpsc::Sender<u8>){
loop {
// println!("running daemon on {}", name); // println!("running daemon on {}", name);
let _ = Command::new("pidof") let _ = Command::new("pidof")
.arg(name) .arg(name)
@ -278,14 +277,11 @@ async fn running_handler(name: &str, path: &str, tx: mpsc::Sender<u8>){
} }
} }
tokio::time::sleep(Duration::from_millis(100)).await; tokio::time::sleep(Duration::from_millis(100)).await;
}
} }
async fn file_handler(name: &str, files: &Vec<Files>, tx: mpsc::Sender<u8>) { async fn file_handler(name: &str, files: &Vec<Files>, tx: mpsc::Sender<u8>) {
loop {
// println!("file daemon on {}", name); // println!("file daemon on {}", name);
if is_active(name) { if is_active(name) {
let mut er = 0;
for file in files { for file in files {
match check_file(&file.filename, &file.src) { match check_file(&file.filename, &file.src) {
Ok(_) => { Ok(_) => {
@ -297,12 +293,10 @@ async fn file_handler(name: &str, files: &Vec<Files>, tx: mpsc::Sender<u8>) {
continue; continue;
}, },
"stop" => { "stop" => {
er += 1;
tx.send(1).await.unwrap(); tx.send(1).await.unwrap();
break; return;
}, },
"hold" => { "hold" => {
er += 1;
tx.send(2).await.unwrap(); tx.send(2).await.unwrap();
break; break;
}, },
@ -314,12 +308,11 @@ async fn file_handler(name: &str, files: &Vec<Files>, tx: mpsc::Sender<u8>) {
}, },
} }
} }
if is_frozen(name) && er == 0 { if is_frozen(name) {
tx.send(10).await.unwrap(); tx.send(10).await.unwrap();
} }
} }
tokio::time::sleep(Duration::from_millis(100)).await; tokio::time::sleep(Duration::from_millis(100)).await;
}
} }
fn check_file(filename: &str, path: &str) -> Result<(), CustomError> { fn check_file(filename: &str, path: &str) -> Result<(), CustomError> {
let fileconcat = format!("{}{}", path, filename); 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<Services>, tx: mpsc::Sender<u8>) { async fn service_handler(name: &str, services: &Vec<Services>, tx: mpsc::Sender<u8>) {
loop {
// println!("service daemon on {}", name); // println!("service daemon on {}", name);
if is_active(name) { if is_active(name) {
let mut er = 0; let mut er = 0;
@ -385,7 +377,6 @@ async fn service_handler(name: &str, services: &Vec<Services>, tx: mpsc::Sender<
} }
} }
tokio::time::sleep(Duration::from_millis(100)).await; tokio::time::sleep(Duration::from_millis(100)).await;
}
} }
async fn looped_service_connecting( async fn looped_service_connecting(