dockerfile fix + get_cont_id fix

pull/9/head
prplV 2024-10-03 13:41:06 +03:00
parent 881b5aa1a2
commit 8fa5533cdf
5 changed files with 19 additions and 12 deletions

View File

@ -8,13 +8,14 @@ RUN mkdir monitor/
RUN mkdir -p services/temp-process/ RUN mkdir -p services/temp-process/
RUN touch services/temp-process/dep.txt RUN touch services/temp-process/dep.txt
RUN touch services/temp-process/run.sh 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 target/x86_64-unknown-linux-gnu/release/runner-rs monitor/
COPY settings.json . COPY settings.json .
COPY temp-process services/temp-process/ COPY temp-process services/temp-process/
RUN chmod +x services/temp-process/temp-process RUN chmod +x services/temp-process/temp-process
RUN chmod +x services/temp-process/run.sh
RUN chmod +x monitor/runner-rs RUN chmod +x monitor/runner-rs
ENTRYPOINT [ "/usr/src/kii/monitor/runner-rs" ] ENTRYPOINT [ "/usr/src/kii/monitor/runner-rs" ]

View File

@ -29,7 +29,7 @@ pub fn get_actual_config() -> Option<Processes> {
"Found local configuration, version - {}", "Found local configuration, version - {}",
&local_conf.date_of_creation &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) { return match config_comparing(&local_conf, &remote_conf) {
ConfigActuality::Local => { ConfigActuality::Local => {
info!("Local config is actual"); info!("Local config is actual");

View File

@ -29,8 +29,8 @@ pub fn setup_logger() -> Result<(), crate::structs::CustomError> {
.format(move |buf, record| { .format(move |buf, record| {
writeln!( writeln!(
buf, 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"), Local::now().format("%d-%m-%Y %H:%M:%S"),
record.level(), record.level(),
record.args(), record.args(),

View File

@ -81,9 +81,7 @@ async fn main() {
// remote config update subscription // remote config update subscription
handler.push(tokio::spawn(async move { handler.push(tokio::spawn(async move {
if subscribe_config_stream(Arc::new(processes)).await.is_err() { let _ = subscribe_config_stream(Arc::new(processes)).await;
return
}
})); }));
for i in handler { for i in handler {

View File

@ -14,8 +14,7 @@ use tokio::join;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use tokio::time::Duration; use tokio::time::Duration;
const GET_ID_CMD: &str = const GET_ID_CMD: &str = "hostname";
r"cat /proc/self/mountinfo | grep '/docker/containers/' | head -1 | awk -F '/' '{print \$6}'";
/// # async func to run 3 main daemons (now it's more like tree-form than classical 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
@ -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}' // todo: cmd across cat /proc/self/mountinfo | grep "/docker/containers/" | head -1 | awk -F '/' '{print $5}'
pub fn get_container_id() -> Option<String> { pub fn get_container_id() -> Option<String> {
match Command::new("sh -c").arg(GET_ID_CMD).output() { match Command::new(GET_ID_CMD).output() {
Ok(output) => Some(String::from_utf8_lossy(&output.stdout).to_string()), Ok(output) => {
Err(_) => None, 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 },
} }
} }