mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-21 18:55:36 +02:00
Merge branch 'task/auth-session-cleanup'
This commit is contained in:
commit
59a37a2ce3
1 changed files with 15 additions and 0 deletions
|
|
@ -26,6 +26,21 @@ async fn main() -> Result<()> {
|
|||
|
||||
let app = routes::app(registry.clone(), auth_db_path.clone());
|
||||
|
||||
// Spawn session cleanup: runs at startup and every 24h.
|
||||
let cleanup_auth_path = auth_db_path.clone();
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
if let Ok(conn) = archivr_core::database::open_auth_db(&cleanup_auth_path) {
|
||||
match archivr_core::database::delete_expired_sessions(&conn) {
|
||||
Ok(n) if n > 0 => eprintln!("info: cleaned up {n} expired sessions"),
|
||||
Err(e) => eprintln!("warn: session cleanup failed: {e:#}"),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(24 * 60 * 60)).await;
|
||||
}
|
||||
});
|
||||
|
||||
let bind_str = std::env::var("ARCHIVR_BIND")
|
||||
.ok()
|
||||
.or_else(|| registry.bind.clone())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue