diff --git a/noxis-rs/src/options/config.rs b/noxis-rs/src/options/config.rs index 1439ae7..cabab29 100644 --- a/noxis-rs/src/options/config.rs +++ b/noxis-rs/src/options/config.rs @@ -18,30 +18,37 @@ pub mod v2 { use super::*; pub async fn init_config_mechanism(cli_oneshot: Arc> /*...*/) { /* local + pubsub + cli oneshot check */ } pub async fn get_pubsub<'a>(params: Arc) -> Option> { - let config_path = params.config.to_str().unwrap_or_else(|| "settings.json"); - - if params.no_sub || params.no_sub { + // let config_path = params.config.to_str().unwrap_or_else(|| "settings.json"); + if params.no_sub { return None; } - if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) { - if let Ok(mut conn) = client.get_connection() { - match crate::utils::get_container_id() { - Some(channel_name) => { - let channel_name = channel_name.trim(); - let mut pubsub = conn.as_pubsub(); - if pubsub.subscribe(&channel_name).is_ok() { + let mut connection_delay: u64 = 1; + loop { + if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) { + if let Ok(mut conn) = client.get_connection() { + match crate::utils::get_container_id() { + Some(channel_name) => { + // let channel_name = channel_name.trim(); + let mut pubsub = conn.as_pubsub(); + if pubsub.subscribe(&channel_name.trim()).is_ok() { - } else { - error!("Cannot subscribe channel {}. Check Redis Server status", &channel_name); + todo!() + + } else { + error!("Cannot subscribe channel {}. Check Redis Server status", &channel_name); + } + }, + None => { + error!("Cannot get channel name"); } - }, - None => { - error!("Cannot get channel name"); } } } + error!("Error with subscribing Redis stream on update. Retrying in {} secs...", connection_delay); + sleep(Duration::from_secs(connection_delay)).await; + connection_delay *= 2; } - error!("Error with subscribing Redis stream on update. Working only with selected config..."); + None } pub async fn get_local_config_watcher(/*...*/) { /*...*/ } @@ -360,7 +367,7 @@ fn restart_main_thread() -> std::io::Result<()> { pub async fn subscribe_config_stream(actual_prcs: Arc, params: Arc) -> Result<(), CustomError> { let config_path = params.config.to_str().unwrap_or_else(|| "settings.json"); - if params.no_sub || params.no_sub { + if params.no_sub { return Err(CustomError::Fatal); } if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) {