Compare commits
2 Commits
ccf474922e
...
d1adc6baf0
| Author | SHA1 | Date |
|---|---|---|
|
|
d1adc6baf0 | |
|
|
9f33396f95 |
17
src/main.rs
17
src/main.rs
|
|
@ -6,7 +6,6 @@ mod utils;
|
||||||
mod services;
|
mod services;
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use std::process::Command;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
|
|
@ -16,8 +15,6 @@ use structs::*;
|
||||||
use config::*;
|
use config::*;
|
||||||
use utils::*;
|
use utils::*;
|
||||||
|
|
||||||
static GET_ID_CMD : &'static str = "cat /proc/self/mountinfo | grep '/docker/containers/' | head -1 | awk -F '/' '{print $6}'";
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
@ -77,16 +74,4 @@ async fn main() {
|
||||||
i.await.unwrap();
|
i.await.unwrap();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: cmd across cat /proc/self/mountinfo | grep "/docker/containers/" | head -1 | awk -F '/' '{print $5}'
|
|
||||||
fn get_container_id() -> Option<String> {
|
|
||||||
match Command::new(GET_ID_CMD).output() {
|
|
||||||
Ok(output) => {
|
|
||||||
Some(String::from_utf8_lossy(&output.stdout).to_string())
|
|
||||||
},
|
|
||||||
Err(_) => {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
16
src/utils.rs
16
src/utils.rs
|
|
@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||||
use crate::structs::TrackingProcess;
|
use crate::structs::TrackingProcess;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use inotify::Inotify;
|
use inotify::Inotify;
|
||||||
|
use std::process::Command;
|
||||||
use crate::files::create_watcher;
|
use crate::files::create_watcher;
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use crate::prcs::{
|
use crate::prcs::{
|
||||||
|
|
@ -18,6 +19,8 @@ use tokio::join;
|
||||||
use crate::files::file_handler;
|
use crate::files::file_handler;
|
||||||
use crate::services::service_handler;
|
use crate::services::service_handler;
|
||||||
|
|
||||||
|
static GET_ID_CMD : &'static str = r"cat /proc/self/mountinfo | grep '/docker/containers/' | head -1 | awk -F '/' '{print \$6}'";
|
||||||
|
|
||||||
/// # async func to run 3 main daemons (now its more like tree-form than classiacl 0.1.0 form )
|
/// # async func to run 3 main daemons (now its more like tree-form than classiacl 0.1.0 form )
|
||||||
/// > hint : give mpsc with capacity 1 to jump over potential errors during running process
|
/// > hint : give mpsc with capacity 1 to jump over potential errors during running process
|
||||||
/// ** in [developing](https://github.com/prplV/runner-rs "REPOSITORY") **
|
/// ** in [developing](https://github.com/prplV/runner-rs "REPOSITORY") **
|
||||||
|
|
@ -157,3 +160,16 @@ pub async fn running_handler
|
||||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||||
tokio::task::yield_now().await;
|
tokio::task::yield_now().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// todo: cmd across cat /proc/self/mountinfo | grep "/docker/containers/" | head -1 | awk -F '/' '{print $5}'
|
||||||
|
pub fn get_container_id() -> Option<String> {
|
||||||
|
match Command::new("sh -c").arg(GET_ID_CMD).output() {
|
||||||
|
Ok(output) => {
|
||||||
|
Some(String::from_utf8_lossy(&output.stdout).to_string())
|
||||||
|
},
|
||||||
|
Err(_) => {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue