|
|
|
@ -63,6 +63,27 @@ async fn main() -> anyhow::Result<()> {
|
|
|
|
tracing::warn!("Failed to load provider rate limits from DB: {:?}. Using defaults.", e);
|
|
|
|
tracing::warn!("Failed to load provider rate limits from DB: {:?}. Using defaults.", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Periodic session cleanup (every hour)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let cleanup_pool = state.pool.clone();
|
|
|
|
|
|
|
|
tokio::spawn(async move {
|
|
|
|
|
|
|
|
let mut interval = tokio::time::interval(std::time::Duration::from_secs(3600));
|
|
|
|
|
|
|
|
loop {
|
|
|
|
|
|
|
|
interval.tick().await;
|
|
|
|
|
|
|
|
match crate::db::sessions::delete_expired(&cleanup_pool).await {
|
|
|
|
|
|
|
|
Ok(count) => {
|
|
|
|
|
|
|
|
if count > 0 {
|
|
|
|
|
|
|
|
tracing::info!(deleted = count, "Cleaned up expired sessions");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
|
|
tracing::warn!(error = %e, "Failed to clean up expired sessions");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let shutdown_pool = state.pool.clone();
|
|
|
|
let shutdown_pool = state.pool.clone();
|
|
|
|
let app = router::build_router(state, &config);
|
|
|
|
let app = router::build_router(state, &config);
|
|
|
|
|
|
|
|
|
|
|
|
|