updated some variables
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2023-04-22 19:04:20 +02:00
parent fe9a577f61
commit 699d12324b
2 changed files with 10 additions and 6 deletions

View File

@ -119,19 +119,23 @@ pub async fn run() {
}
let ctxclone = Arc::clone(&ctxarc);
handle_cfg_reload(ctxclone, &mut last_cfg_reload).await;
handle_cfg_reload(&ctxclone, &mut last_cfg_reload).await;
drop(ctxclone);
}
}
async fn handle_cfg_reload(ctxclone: Arc<RwLock<Context>>, last_cfg_reload: &mut DateTime<Local>) {
async fn handle_cfg_reload(ctxclone: &Arc<RwLock<Context>>, last_cfg_reload: &mut DateTime<Local>) {
let now_cfg_reload = Local::now().trunc_subsecs(0);
if (now_cfg_reload - *last_cfg_reload) > Duration::seconds(5) {
let mut ctx = ctxclone.write().await;
match ctx.load().await {
Ok(_) => {
*last_cfg_reload = Local::now().trunc_subsecs(0);
drop(ctx);
}
Err(_) => {
println!("error reloading config");
}
Err(_) => {}
}
};
}

View File

@ -81,14 +81,14 @@ pub async fn websocketconnect<'a>(
(socket, _) = match connect(&wscfg.endpoint) {
Ok((o, e)) => (o, e),
_ => {
println!("error connecting, retrying");
println!("error connecting to {}, retrying", &wscfg.endpoint);
sleep_s(1).await;
continue;
}
};
break;
}
println!("connected");
println!("connected to {}", &wscfg.endpoint);
let msg = json!({ "hostname": hostname });
socket
.write_message(Message::Text(msg.to_string()))