Automatically reload config every seconds (disabled by default) (#86)

* Automatically reload config every seconds (disabld by default)

* add that
This commit is contained in:
Lev Kokotov
2022-06-25 11:46:20 -07:00
committed by GitHub
parent f06f64119c
commit 5bcd3bf9c3
5 changed files with 41 additions and 9 deletions

View File

@@ -127,6 +127,7 @@ async fn main() {
// Save these for reloading
let reload_client_server_map = client_server_map.clone();
let autoreload_client_server_map = client_server_map.clone();
let addresses = pool.databases();
tokio::task::spawn(async move {
@@ -203,6 +204,26 @@ async fn main() {
}
});
if config.general.autoreload {
let mut interval = tokio::time::interval(tokio::time::Duration::from_millis(15_000));
tokio::task::spawn(async move {
info!("Config autoreloader started");
loop {
interval.tick().await;
match reload_config(autoreload_client_server_map.clone()).await {
Ok(changed) => {
if changed {
get_config().show()
}
}
Err(_) => (),
};
}
});
}
// Exit on Ctrl-C (SIGINT) and SIGTERM.
let mut term_signal = unix_signal(SignalKind::terminate()).unwrap();