joinhandlers ending is catching and processing
parent
98da769dd3
commit
6adab1b903
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"dateOfCreation": "1721381809106",
|
||||
"dateOfCreation": "1721381809107",
|
||||
"configServer": "localhost",
|
||||
"processes": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,25 +44,30 @@ pub mod v2 {
|
|||
|
||||
// dbg!("before lc");
|
||||
let params_clone = params.clone();
|
||||
let for_lc_path = params.clone();
|
||||
let lc_path = for_lc_path
|
||||
.config
|
||||
.to_str()
|
||||
.unwrap_or("settings.json");
|
||||
|
||||
// future to init work with local config
|
||||
let lc_future = tokio::spawn(async move {
|
||||
// let params = params.clone();
|
||||
let _ = local_config_reciever(
|
||||
local_config_reciever(
|
||||
params_clone,
|
||||
rx_pb_lc,
|
||||
rx_cli_lc,
|
||||
Arc::new(brd_tx)
|
||||
).await;
|
||||
).await
|
||||
});
|
||||
// dbg!("before pb");
|
||||
// future to init work with pub sub mechanism
|
||||
let pubsub_future = tokio::spawn(async move {
|
||||
let _ = pubsub_config_reciever(
|
||||
pubsub_config_reciever(
|
||||
tx_pb_lc,
|
||||
params.clone(),
|
||||
local_config_brd_reciever
|
||||
).await;
|
||||
).await
|
||||
});
|
||||
|
||||
// dbg!("before cli");
|
||||
|
|
@ -71,15 +76,68 @@ pub mod v2 {
|
|||
from_cli_config_reciever(
|
||||
cli_oneshot,
|
||||
tx_cli_lc
|
||||
).await;
|
||||
).await
|
||||
|
||||
});
|
||||
// let _ = lc_future.await;
|
||||
// dbg!("before select");
|
||||
tokio::select! {
|
||||
lc_result = lc_future => {dbg!("end of lc");},
|
||||
pb_result = pubsub_future => {dbg!("end of pb");},
|
||||
cli_config_option = cli_future => {dbg!("end of cli");},
|
||||
lc_result = lc_future => {
|
||||
// dbg!("end of lc");
|
||||
match lc_result {
|
||||
Ok(res) => {
|
||||
if res.is_ok() {
|
||||
info!("Local config warding mechanism stopped, waiting for others ...");
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
}
|
||||
else {
|
||||
error!("Local config warding mechanism crushed, restarting ...");
|
||||
let _ = restart_main_thread();
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
error!("Local config warding mechanism crushed, restarting ...");
|
||||
let _ = restart_main_thread();
|
||||
},
|
||||
}
|
||||
},
|
||||
pb_result = pubsub_future => {
|
||||
match pb_result {
|
||||
Ok(res) => {
|
||||
if res.is_ok() {
|
||||
info!("New config was saved locally, restarting ...");
|
||||
}
|
||||
else {
|
||||
error!("Pubsub mechanism crushed, restarting ...");
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
error!("Pubsub mechanism crushed, restarting ...");
|
||||
},
|
||||
}
|
||||
let _ = restart_main_thread();
|
||||
},
|
||||
cli_config_option = cli_future => {
|
||||
// match cli_config_option {
|
||||
// Some(config) => {},
|
||||
// None => {
|
||||
// error!("Cli pulling new config mechanism crushed, restarting ...")
|
||||
// },
|
||||
// }
|
||||
match cli_config_option {
|
||||
Err(_) => error!("Cli pulling new config mechanism crushed, restarting ..."),
|
||||
Ok(option_config) => {
|
||||
match option_config {
|
||||
None => error!("Cli pulling new config mechanism crushed, restarting ..."),
|
||||
Some(config) => {
|
||||
info!("New config was pulled from CLI, saving and restarting ...");
|
||||
let _ = save_new_config(&config, lc_path);
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
let _ = restart_main_thread();
|
||||
},
|
||||
}
|
||||
// dbg!("after select");
|
||||
// TODO! futures + select! [OK]
|
||||
|
|
|
|||
Loading…
Reference in New Issue