From 41f98bc8500208b555401cc91deb885ba26f7abf Mon Sep 17 00:00:00 2001 From: prplV Date: Tue, 27 Aug 2024 11:39:18 +0300 Subject: [PATCH] patch is_frozen + logs + no comments --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 32 +++++++++++--------------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6475956..029d9d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -499,7 +499,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "runner-rs" -version = "0.5.0" +version = "0.5.1" dependencies = [ "chrono", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index b1b7473..4fac11d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runner-rs" -version = "0.5.0" +version = "0.5.1" edition = "2021" [dependencies] diff --git a/src/main.rs b/src/main.rs index fa3c6a6..aa08605 100644 --- a/src/main.rs +++ b/src/main.rs @@ -108,6 +108,7 @@ struct FIleTriggers { #[tokio::main(flavor = "multi_thread")] async fn main() { + // building logger with current output format Builder::new() .format(|buf, record|{ @@ -121,14 +122,17 @@ async fn main() { .filter(None, LevelFilter::Info) .init(); + log::info!("Runner is configurating..."); + // setting up redis connection \ // then conf checks to choose the most actual \ let processes: Processes = get_actual_config().unwrap_or_else(|| { - error!("No actual configuration for runner"); + error!("No actual configuration for runner. Stopping..."); std::process::exit(101); }); - - log::info!("Current runner configuration: {}\n", &processes.date_of_creation); + + log::info!("Current runner configuration: {}", &processes.date_of_creation); + log::info!("Runner is ready. Initializing..."); if processes.processes.len() == 0 { error!("Processes list is null, runner-rs initialization is stopped"); @@ -353,23 +357,7 @@ async fn create_watcher(filename: &str, path: &str) -> Result bool { .await .unwrap() } + +// T is for stopped processes async fn is_frozen(name: &str) -> bool { let temp = get_pid(name).await; let pid = String::from_utf8_lossy(&temp.stdout); @@ -558,7 +548,7 @@ async fn is_frozen(name: &str) -> bool { error!("Failed to execute ps command"); std::process::exit(101); }); - !(String::from_utf8_lossy(&cmd.stdout) == "Sl+\n") + String::from_utf8_lossy(&cmd.stdout).contains("T") }) .await .unwrap()