docs: utils
parent
adb3858ee4
commit
e89d1be8e4
44
src/utils.rs
44
src/utils.rs
|
|
@ -22,9 +22,21 @@ use tokio::time::Duration;
|
||||||
|
|
||||||
const GET_ID_CMD: &str = "hostname";
|
const GET_ID_CMD: &str = "hostname";
|
||||||
|
|
||||||
/// # async func to run 3 main daemons (now it's more like tree-form than classical 0.1.0 form )
|
/// # Fn `run_daemons`
|
||||||
/// > hint : give mpsc with capacity 1 to jump over potential errors during running process
|
/// ## async func to run 3 main daemons: process, service and file monitors and manage process state according to given messages into channel
|
||||||
/// > ** in [developing](https://github.com/prplV/runner-rs "REPOSITORY") **
|
///
|
||||||
|
/// *input* : `Arc<TrackingProcess>`, `Arc<mpsc::Sender<u8>>`, `&mut mpsc::Receiver<u8>`,
|
||||||
|
///
|
||||||
|
/// *output* : ()
|
||||||
|
///
|
||||||
|
/// *initiator* : main thread
|
||||||
|
///
|
||||||
|
/// *managing* : Arc to current process struct, Arc to managing channel writer, mut ref to managing channel reader
|
||||||
|
///
|
||||||
|
/// *depends on* : all module `prcs`'s functions, fn `running_handler`, fn `utils::files::create_watcher`
|
||||||
|
///
|
||||||
|
/// > *hint* : give mpsc with capacity 1 to jump over potential errors during running process
|
||||||
|
///
|
||||||
pub async fn run_daemons(
|
pub async fn run_daemons(
|
||||||
proc: Arc<TrackingProcess>,
|
proc: Arc<TrackingProcess>,
|
||||||
tx: Arc<mpsc::Sender<u8>>,
|
tx: Arc<mpsc::Sender<u8>>,
|
||||||
|
|
@ -167,6 +179,19 @@ pub async fn run_daemons(
|
||||||
tokio::task::yield_now().await;
|
tokio::task::yield_now().await;
|
||||||
}
|
}
|
||||||
// check process status daemon
|
// check process status daemon
|
||||||
|
/// # Fn `run_daemons`
|
||||||
|
/// ## func to async exec subjobs of checking process, services and files states
|
||||||
|
///
|
||||||
|
/// *input* : `Arc<TrackingProcess>`, `Arc<mpsc::Sender<u8>>`, `Arc<tokio::sync::Mutex<Vec<Inotify>>>`
|
||||||
|
///
|
||||||
|
/// *output* : ()
|
||||||
|
///
|
||||||
|
/// *initiator* : fn `run_daemons`
|
||||||
|
///
|
||||||
|
/// *managing* : Arc to current process struct, Arc to Mutex to list of file watchers
|
||||||
|
///
|
||||||
|
/// *depends on* : fn `utils::files::file_handler`, fn `utils::services::service_handler`, fn `utils::prcs::{is_active, is_frozen, start_process}`
|
||||||
|
///
|
||||||
pub async fn running_handler(
|
pub async fn running_handler(
|
||||||
prc: Arc<TrackingProcess>,
|
prc: Arc<TrackingProcess>,
|
||||||
tx: Arc<mpsc::Sender<u8>>,
|
tx: Arc<mpsc::Sender<u8>>,
|
||||||
|
|
@ -199,6 +224,19 @@ pub async fn running_handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: cmd across cat /proc/self/mountinfo | grep "/docker/containers/" | head -1 | awk -F '/' '{print $5}'
|
// todo: cmd across cat /proc/self/mountinfo | grep "/docker/containers/" | head -1 | awk -F '/' '{print $5}'
|
||||||
|
/// # Fn `get_container_id`
|
||||||
|
/// ## for getting container id used in logs
|
||||||
|
///
|
||||||
|
/// *input* : -
|
||||||
|
///
|
||||||
|
/// *output* : Some(String) if cont-id was grubbed | None - if not
|
||||||
|
///
|
||||||
|
/// *initiator* : fn `options::logger::setup_logger`
|
||||||
|
///
|
||||||
|
/// *managing* : -
|
||||||
|
///
|
||||||
|
/// *depends on* : -
|
||||||
|
///
|
||||||
pub fn get_container_id() -> Option<String> {
|
pub fn get_container_id() -> Option<String> {
|
||||||
match Command::new(GET_ID_CMD).output() {
|
match Command::new(GET_ID_CMD).output() {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue