local logs (nw)
parent
d1adc6baf0
commit
e2d2100ce9
|
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
.idea
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
hostname=$1
|
|
||||||
port=$2
|
|
||||||
|
|
||||||
if nc -z -w1 $hostname $port > /dev/null 2>&1; then
|
|
||||||
echo "Service $hostname:$port is running"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Service $hostname:$port is unreachable"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
14
src/main.rs
14
src/main.rs
|
|
@ -5,9 +5,12 @@ mod prcs;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod services;
|
mod services;
|
||||||
|
|
||||||
|
// use tokio::fs::File;
|
||||||
|
use std::fs::{File, OpenOptions};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::process::Command;
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
use env_logger::Builder;
|
use env_logger::Builder;
|
||||||
use log::{error, LevelFilter};
|
use log::{error, LevelFilter};
|
||||||
|
|
@ -19,6 +22,15 @@ use utils::*;
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
||||||
|
if Command::new("sh").args(["-c", "'mkdir /var/log/runner-rs/'"]).output().is_err() {
|
||||||
|
println!("Error: Run runner in sudo mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
let log_target = Box::new(OpenOptions::new().create_new(true).append(true).open("/var/log/runner-rs/runner.log").unwrap_or_else(|_| {
|
||||||
|
println!("Error: Cannot create local log-file in /var/log/runner-rs, returning...");
|
||||||
|
std::process::exit(1);
|
||||||
|
}));
|
||||||
|
|
||||||
// building logger with current output format
|
// building logger with current output format
|
||||||
Builder::new()
|
Builder::new()
|
||||||
.format(move |buf, record|{
|
.format(move |buf, record|{
|
||||||
|
|
@ -30,6 +42,8 @@ async fn main() {
|
||||||
record.args(),
|
record.args(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.target(env_logger::Target::Stdout)
|
||||||
|
.target(env_logger::Target::Pipe(log_target))
|
||||||
.filter(None, LevelFilter::Info)
|
.filter(None, LevelFilter::Info)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ 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}'";
|
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 it's more like tree-form than classical 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") **
|
||||||
pub async fn run_daemons(
|
pub async fn run_daemons(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue