Compare commits
No commits in common. "d1adc6baf0c2d92f2674b09395b1127abdabc281" and "ccf474922efbabfb630071b596fc1083a10197fb" have entirely different histories.
d1adc6baf0
...
ccf474922e
15
src/main.rs
15
src/main.rs
|
|
@ -6,6 +6,7 @@ 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;
|
||||||
|
|
@ -15,6 +16,8 @@ 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() {
|
||||||
|
|
@ -75,3 +78,15 @@ async fn main() {
|
||||||
}
|
}
|
||||||
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,7 +2,6 @@ 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::{
|
||||||
|
|
@ -19,8 +18,6 @@ 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") **
|
||||||
|
|
@ -160,16 +157,3 @@ 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