patch is_frozen + logs + no comments
parent
84d47813a2
commit
41f98bc850
|
|
@ -499,7 +499,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
|||
|
||||
[[package]]
|
||||
name = "runner-rs"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"env_logger",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "runner-rs"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
|||
32
src/main.rs
32
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<Inotify, std::io::
|
|||
&src,
|
||||
WatchMask::ALL_EVENTS
|
||||
);
|
||||
// !
|
||||
// // let _ = stream
|
||||
// // .watches()
|
||||
// // .add(
|
||||
// // &src,
|
||||
// // WatchMask::ALL_EVENTS
|
||||
// // );
|
||||
// while let Some(a) = stream.next().await {
|
||||
// // println!("event - {:?}", a);
|
||||
// if a.unwrap().mask == EventMask::MODIFY {
|
||||
// counter+=1;
|
||||
// println!("mod {} - {:?}", counter, stream);
|
||||
// }
|
||||
// }
|
||||
|
||||
// todo!();
|
||||
// !
|
||||
|
||||
Ok(inotify)
|
||||
}
|
||||
|
||||
|
|
@ -542,6 +530,8 @@ async fn is_active(name: &str)-> 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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue