diff --git a/Dockerfile b/Dockerfile index 07663ea..ca5edfc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,13 +8,14 @@ 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 +RUN echo "./services/temp-process/temp-process &>/dev/null" >> services/temp-process/run.sh COPY target/x86_64-unknown-linux-gnu/release/runner-rs monitor/ COPY settings.json . COPY temp-process services/temp-process/ RUN chmod +x services/temp-process/temp-process +RUN chmod +x services/temp-process/run.sh RUN chmod +x monitor/runner-rs ENTRYPOINT [ "/usr/src/kii/monitor/runner-rs" ] diff --git a/src/config.rs b/src/config.rs index 0fb7934..e1d3459 100644 --- a/src/config.rs +++ b/src/config.rs @@ -29,7 +29,7 @@ pub fn get_actual_config() -> Option { "Found local configuration, version - {}", &local_conf.date_of_creation ); - if let Some(remote_conf) = once_get_remote_configuration("redis://localhost") { + if let Some(remote_conf) = once_get_remote_configuration("redis://172.19.32.198:6379/") { return match config_comparing(&local_conf, &remote_conf) { ConfigActuality::Local => { info!("Local config is actual"); diff --git a/src/logger.rs b/src/logger.rs index b8a486d..9a1b821 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -29,8 +29,8 @@ pub fn setup_logger() -> Result<(), crate::structs::CustomError> { .format(move |buf, record| { writeln!( buf, - "Container-{}| {} [{}] - {}", - get_container_id().unwrap_or("||NODE|".to_string()), + "|{}| {} [{}] - {}", + get_container_id().unwrap_or("NODE".to_string()).trim(), Local::now().format("%d-%m-%Y %H:%M:%S"), record.level(), record.args(), diff --git a/src/main.rs b/src/main.rs index 529983e..0ee2df5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,9 +81,7 @@ async fn main() { // remote config update subscription handler.push(tokio::spawn(async move { - if subscribe_config_stream(Arc::new(processes)).await.is_err() { - return - } + let _ = subscribe_config_stream(Arc::new(processes)).await; })); for i in handler { diff --git a/src/utils.rs b/src/utils.rs index c8915f7..63d454b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -14,8 +14,7 @@ use tokio::join; use tokio::sync::mpsc; use tokio::time::Duration; -const GET_ID_CMD: &str = - r"cat /proc/self/mountinfo | grep '/docker/containers/' | head -1 | awk -F '/' '{print \$6}'"; +const GET_ID_CMD: &str = "hostname"; /// # 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 @@ -183,8 +182,17 @@ pub async fn running_handler( // todo: cmd across cat /proc/self/mountinfo | grep "/docker/containers/" | head -1 | awk -F '/' '{print $5}' pub fn get_container_id() -> Option { - match Command::new("sh -c").arg(GET_ID_CMD).output() { - Ok(output) => Some(String::from_utf8_lossy(&output.stdout).to_string()), - Err(_) => None, + match Command::new(GET_ID_CMD).output() { + Ok(output) => { + if !output.status.success() { + return None; + } + let id = String::from_utf8_lossy(&output.stdout).to_string(); + if id.is_empty() { + return None + } + Some(String::from_utf8_lossy(&output.stdout).to_string()) + }, + Err(er) => { println!("failed( : {}", er); None }, } }