Compare commits
No commits in common. "8617a105e231d6d95a94008726489415838762a5" and "41f98bc8500208b555401cc91deb885ba26f7abf" have entirely different histories.
8617a105e2
...
41f98bc850
20
Dockerfile
20
Dockerfile
|
|
@ -1,20 +0,0 @@
|
|||
FROM ubuntu
|
||||
|
||||
RUN mkdir -p /usr/src/kii/
|
||||
|
||||
WORKDIR /usr/src/kii/
|
||||
|
||||
RUN mkdir monitor/
|
||||
RUN mkdir -p services/temp-process/
|
||||
RUN touch services/temp-process/dep.txt
|
||||
RUN touch services/temp-process/run.sh
|
||||
RUN echo "./services/temp-process/temp-process" >> services/temp-process/run.sh
|
||||
|
||||
COPY runner-rs monitor/
|
||||
COPY settings.json .
|
||||
COPY temp-process services/temp-process/
|
||||
|
||||
RUN chmod +x services/temp-process/temp-process
|
||||
RUN chmod +x monitor/runner-rs
|
||||
|
||||
ENTRYPOINT [ "/usr/src/kii/monitor/runner-rs" ]
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"id": 1,
|
||||
"dateOfCreation": "1721381809090",
|
||||
"processes": [
|
||||
{
|
||||
|
|
@ -15,7 +16,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"filename": "config-file",
|
||||
"filename": "config-file.json",
|
||||
"src": "/home/vladislav/web/",
|
||||
"triggers": {
|
||||
"onDelete": "stop",
|
||||
|
|
@ -52,8 +53,8 @@
|
|||
],
|
||||
"services": [
|
||||
{
|
||||
"hostname": "google.com",
|
||||
"port": 443,
|
||||
"hostname": "localhost",
|
||||
"port": 6379,
|
||||
"triggers": {
|
||||
"wait": 14,
|
||||
"delay": 1,
|
||||
|
|
|
|||
24
src/main.rs
24
src/main.rs
|
|
@ -6,6 +6,7 @@ use serde_json;
|
|||
use tokio::time::{ Duration, Instant };
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::join;
|
||||
// use tokio::io::{AsyncRead, AsyncWrite};
|
||||
// fatal errors handler
|
||||
use core::panic;
|
||||
use std::borrow::BorrowMut;
|
||||
|
|
@ -25,7 +26,6 @@ use log::{error, info, warn, LevelFilter};
|
|||
use std::net::{TcpStream, ToSocketAddrs};
|
||||
|
||||
static CONFIG_PATH : &'static str = "settings.json";
|
||||
static GET_ID_CMD : &'static str = "cat /proc/self/mountinfo | grep '/docker/containers/' | head -1 | awk -F '/' '{print $5}'";
|
||||
|
||||
/// # an Error enum (nextly will be deleted and replaced)
|
||||
enum CustomError {
|
||||
|
|
@ -40,8 +40,8 @@ enum ConfigActuality {
|
|||
/// > (needed in serialization and deserialization)
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
struct Processes {
|
||||
// #[serde(rename="id")]
|
||||
// runner_id: usize,
|
||||
#[serde(rename="id")]
|
||||
runner_id: usize,
|
||||
#[serde(rename="dateOfCreation")]
|
||||
date_of_creation : String,
|
||||
#[serde(default)]
|
||||
|
|
@ -108,12 +108,12 @@ struct FIleTriggers {
|
|||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() {
|
||||
|
||||
|
||||
// building logger with current output format
|
||||
Builder::new()
|
||||
.format(move |buf, record|{
|
||||
.format(|buf, record|{
|
||||
writeln!(buf,
|
||||
"Container-{}| {} [{}] - {}",
|
||||
get_container_id().unwrap_or("||undefined container id|".to_string()),
|
||||
"{} [{}] - {}",
|
||||
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
||||
record.level(),
|
||||
record.args(),
|
||||
|
|
@ -830,16 +830,4 @@ async fn check_service(hostname: &str, port: &u32) -> Result<(), CustomError> {
|
|||
},
|
||||
Err(_) => return Err(CustomError::Fatal),
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
},
|
||||
}
|
||||
}
|
||||
BIN
temp-process
BIN
temp-process
Binary file not shown.
Loading…
Reference in New Issue