local logs (nw)
parent
d1adc6baf0
commit
e2d2100ce9
|
|
@ -1 +1,2 @@
|
|||
/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
|
||||
|
||||
28
src/main.rs
28
src/main.rs
|
|
@ -5,9 +5,12 @@ mod prcs;
|
|||
mod utils;
|
||||
mod services;
|
||||
|
||||
// use tokio::fs::File;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use tokio::sync::mpsc;
|
||||
use std::sync::Arc;
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
use chrono::Local;
|
||||
use env_logger::Builder;
|
||||
use log::{error, LevelFilter};
|
||||
|
|
@ -19,7 +22,16 @@ use utils::*;
|
|||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() {
|
||||
|
||||
// building logger with current output format
|
||||
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
|
||||
Builder::new()
|
||||
.format(move |buf, record|{
|
||||
writeln!(buf,
|
||||
|
|
@ -30,18 +42,20 @@ async fn main() {
|
|||
record.args(),
|
||||
)
|
||||
})
|
||||
.target(env_logger::Target::Stdout)
|
||||
.target(env_logger::Target::Pipe(log_target))
|
||||
.filter(None, LevelFilter::Info)
|
||||
.init();
|
||||
|
||||
log::info!("Runner is configurating...");
|
||||
|
||||
// setting up redis connection \
|
||||
// then conf checks to choose the most actual \
|
||||
// then conf checks to choose the most actual \
|
||||
let processes: Processes = get_actual_config().unwrap_or_else(|| {
|
||||
error!("No actual configuration for runner. Stopping...");
|
||||
std::process::exit(101);
|
||||
});
|
||||
|
||||
|
||||
log::info!("Current runner configuration: {}", &processes.date_of_creation);
|
||||
log::info!("Runner is ready. Initializing...");
|
||||
|
||||
|
|
@ -53,13 +67,13 @@ async fn main() {
|
|||
|
||||
for proc in processes.processes.iter() {
|
||||
log::info!("Process '{}' on stage: {}. Depends on {} file(s), {} service(s)",
|
||||
proc.name,
|
||||
proc.path,
|
||||
proc.dependencies.files.len(),
|
||||
proc.name,
|
||||
proc.path,
|
||||
proc.dependencies.files.len(),
|
||||
proc.dependencies.services.len()
|
||||
);
|
||||
|
||||
// creating msg channel
|
||||
// creating msg channel
|
||||
// can or should be executed in new thread
|
||||
let (tx, mut rx) = mpsc::channel::<u8>(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -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}'";
|
||||
|
||||
/// # 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
|
||||
/// ** in [developing](https://github.com/prplV/runner-rs "REPOSITORY") **
|
||||
pub async fn run_daemons(
|
||||
|
|
|
|||
Loading…
Reference in New Issue