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",
|
"dateOfCreation": "1721381809090",
|
||||||
"processes": [
|
"processes": [
|
||||||
{
|
{
|
||||||
|
|
@ -15,7 +16,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "config-file",
|
"filename": "config-file.json",
|
||||||
"src": "/home/vladislav/web/",
|
"src": "/home/vladislav/web/",
|
||||||
"triggers": {
|
"triggers": {
|
||||||
"onDelete": "stop",
|
"onDelete": "stop",
|
||||||
|
|
@ -52,8 +53,8 @@
|
||||||
],
|
],
|
||||||
"services": [
|
"services": [
|
||||||
{
|
{
|
||||||
"hostname": "google.com",
|
"hostname": "localhost",
|
||||||
"port": 443,
|
"port": 6379,
|
||||||
"triggers": {
|
"triggers": {
|
||||||
"wait": 14,
|
"wait": 14,
|
||||||
"delay": 1,
|
"delay": 1,
|
||||||
|
|
|
||||||
24
src/main.rs
24
src/main.rs
|
|
@ -6,6 +6,7 @@ use serde_json;
|
||||||
use tokio::time::{ Duration, Instant };
|
use tokio::time::{ Duration, Instant };
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::join;
|
use tokio::join;
|
||||||
|
// use tokio::io::{AsyncRead, AsyncWrite};
|
||||||
// fatal errors handler
|
// fatal errors handler
|
||||||
use core::panic;
|
use core::panic;
|
||||||
use std::borrow::BorrowMut;
|
use std::borrow::BorrowMut;
|
||||||
|
|
@ -25,7 +26,6 @@ use log::{error, info, warn, LevelFilter};
|
||||||
use std::net::{TcpStream, ToSocketAddrs};
|
use std::net::{TcpStream, ToSocketAddrs};
|
||||||
|
|
||||||
static CONFIG_PATH : &'static str = "settings.json";
|
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)
|
/// # an Error enum (nextly will be deleted and replaced)
|
||||||
enum CustomError {
|
enum CustomError {
|
||||||
|
|
@ -40,8 +40,8 @@ enum ConfigActuality {
|
||||||
/// > (needed in serialization and deserialization)
|
/// > (needed in serialization and deserialization)
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
struct Processes {
|
struct Processes {
|
||||||
// #[serde(rename="id")]
|
#[serde(rename="id")]
|
||||||
// runner_id: usize,
|
runner_id: usize,
|
||||||
#[serde(rename="dateOfCreation")]
|
#[serde(rename="dateOfCreation")]
|
||||||
date_of_creation : String,
|
date_of_creation : String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
@ -108,12 +108,12 @@ struct FIleTriggers {
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
||||||
|
|
||||||
// building logger with current output format
|
// building logger with current output format
|
||||||
Builder::new()
|
Builder::new()
|
||||||
.format(move |buf, record|{
|
.format(|buf, record|{
|
||||||
writeln!(buf,
|
writeln!(buf,
|
||||||
"Container-{}| {} [{}] - {}",
|
"{} [{}] - {}",
|
||||||
get_container_id().unwrap_or("||undefined container id|".to_string()),
|
|
||||||
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
||||||
record.level(),
|
record.level(),
|
||||||
record.args(),
|
record.args(),
|
||||||
|
|
@ -830,16 +830,4 @@ async fn check_service(hostname: &str, port: &u32) -> Result<(), CustomError> {
|
||||||
},
|
},
|
||||||
Err(_) => return Err(CustomError::Fatal),
|
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