diff --git a/src/main.rs b/src/main.rs index 8b13b18..0edac9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,11 +6,9 @@ extern crate ini; extern crate exitcode; use std::env; -use std::ffi::OsStr; use std::path::Path; use std::thread; use std::time::Duration; -use sysinfo::System; mod mods; @@ -43,34 +41,6 @@ async fn check(rule: &Rule) -> bool { }; } -/// Check is process running -/// -/// # Arguments -/// -/// * `process_name` Process name to be checked -/// -/// # Example -/// -/// ``` -/// if check_process("httpd".to_string()).await { -/// println!("ok"); -/// } else { -/// println!("uh-oh... something wrong!"); -/// } -/// ``` -fn check_process(process_name: String) -> bool { - let mut sys = System::new_all(); - let mut result: bool = false; - - sys.refresh_all(); - - for _process in sys.processes_by_exact_name(OsStr::new(&process_name)) { - result = true; - } - - return result; -} - /// Checks web-service availability /// /// # Arguments diff --git a/src/mods/mod_os.rs b/src/mods/mod_os.rs index 21cf894..e514c78 100644 --- a/src/mods/mod_os.rs +++ b/src/mods/mod_os.rs @@ -1,8 +1,38 @@ +use std::ffi::OsStr; use std::process::Command; +use sysinfo::System; use crate::mods::mod_debug::*; use crate::mods::mod_i18n::*; +/// Check is process running +/// +/// # Arguments +/// +/// * `process_name` Process name to be checked +/// +/// # Example +/// +/// ``` +/// if check_process("httpd".to_string()).await { +/// println!("ok"); +/// } else { +/// println!("uh-oh... something wrong!"); +/// } +/// ``` +pub fn check_process(process_name: String) -> bool { + let mut sys = System::new_all(); + let mut result: bool = false; + + sys.refresh_all(); + + for _process in sys.processes_by_exact_name(OsStr::new(&process_name)) { + result = true; + } + + return result; +} + /// Execute shell command /// /// In linux sh command interpreter will be called.