misc updates
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2023-04-29 11:11:11 +02:00
parent 1bef25165a
commit 09be314a97
2 changed files with 5 additions and 6 deletions

View File

@ -17,7 +17,8 @@ use std::path::Path;
pub const GIT_VERSION: &str = git_version!();
const MASTERSERVER: &str = "ipbl.paulbsd.com";
const WSSUBSCRIPTION: &str = "ipbl";
const CONFIG_RETRY: u64 = 5;
const CONFIG_RETRY: u64 = 1;
const WEB_CLIENT_TIMEOUT: i64 = 5;
#[derive(Debug, Clone)]
pub struct Context {
@ -73,7 +74,7 @@ impl Context {
GIT_VERSION,
gethostname(false)
))
.timeout(Duration::seconds(15).to_std().unwrap())
.timeout(Duration::seconds(WEB_CLIENT_TIMEOUT).to_std().unwrap())
.build()
.unwrap(),
sas: HashMap::new(),
@ -134,7 +135,8 @@ impl Context {
}
let mut last_in_err = false;
loop {
match self.cfg.load(self.to_owned()).await {
let res = self.cfg.load(self.clone()).await;
match res {
Ok(()) => {
if last_in_err {
println!("loaded config");

View File

@ -104,7 +104,6 @@ pub async fn run() {
wssocketrr = websocketreqrep(&ctxwsrr).await;
continue;
}
}
}
}
@ -121,7 +120,6 @@ pub async fn run() {
let ctxclone = Arc::clone(&ctxarc);
handle_cfg_reload(&ctxclone, &mut last_cfg_reload).await;
drop(ctxclone);
}
}
@ -132,7 +130,6 @@ async fn handle_cfg_reload(ctxclone: &Arc<RwLock<Context>>, last_cfg_reload: &mu
match ctx.load().await {
Ok(_) => {
*last_cfg_reload = Local::now().trunc_subsecs(0);
drop(ctx);
}
Err(_) => {
println!("error reloading config");