From df3934452b505fa77abb3053a2a0e37ed06ee569 Mon Sep 17 00:00:00 2001 From: prplV Date: Thu, 22 May 2025 09:31:18 +0300 Subject: [PATCH] brd listener for cli - cli ini only after config pull from brd ?? --- noxis-rs/src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/noxis-rs/src/main.rs b/noxis-rs/src/main.rs index 7a1ca45..68a179d 100644 --- a/noxis-rs/src/main.rs +++ b/noxis-rs/src/main.rs @@ -29,6 +29,8 @@ async fn main() -> anyhow::Result<()>{ info!("Noxis is configurating..."); // let (tx_brd, mut rx_brd) = broadcast::channel::(1); + // for cli to get config + let mut rx_cli_brd = tx_brd.subscribe(); // cli <-> config let (tx_oneshot, rx_oneshot) = oneshot::channel::(); let mut handler: Vec> = vec![]; @@ -47,7 +49,17 @@ async fn main() -> anyhow::Result<()>{ // initilaizing task for cli manipulation let preboot_cli = preboot.clone(); let cli_module = tokio::spawn(async move { - if let Err(er) = init_cli_pipeline(preboot_cli).await { + let config = { + let mut tick = tokio::time::interval(Duration::from_millis(500)); + loop { + tick.tick().await; + break match rx_cli_brd.try_recv() { + Ok(conf) => conf, + Err(_) => continue, + } + } + }; + if let Err(er) = init_cli_pipeline(preboot_cli, Arc::new(config)).await { error!("CLI pipeline failed due to {}", er) } });