configurable health check duration

This commit is contained in:
Brandon Thomas committed 2023-03-08 18:49:56 -05:00
1 parent d93c0a5a8d
commit a1e4ca35cd
2 files changed
+11 -3

No files matched your search

@@ -293,6 +293,9 @@ async fn main() -> AnyhowResult<()> {
let twitch_secrets = TwitchSecrets::from_env()?;
let health_check_interval = easyenv::get_env_duration_seconds_or_default(
"HEALTH_CHECK_INTERVAL_SECS", Duration::from_secs(3));
let static_api_token_set = read_static_api_tokens();
// Background jobs.
@@ -308,8 +311,12 @@ async fn main() -> AnyhowResult<()> {
info!("Spawning DB health checker thread.");
tokio_runtime.spawn(async {
db_health_checker_thread(health_check_status2, mysql_pool3).await;
tokio_runtime.spawn(async move {
db_health_checker_thread(
health_check_status2,
mysql_pool3,
health_check_interval,
).await;
});
info!("Spawning IP ban polling thread.");
@@ -12,6 +12,7 @@ use std::time::Duration;
pub async fn db_health_checker_thread(
health_check_status: HealthCheckStatus,
mysql_pool: MySqlPool,
check_duration: Duration,
) {
loop {
debug!("Checking DB health...");
@@ -32,7 +33,7 @@ pub async fn db_health_checker_thread(
}
}
thread::sleep(Duration::from_millis(3_000));
thread::sleep(check_duration);
}
warn!("Should never happen: Health Checker Exits");