Spawn a background task that periodically reaps expired and revoked SSH sessions.
(store: Arc<Store>, interval: Duration)
| 21 | |
| 22 | /// Spawn a background task that periodically reaps expired and revoked SSH sessions. |
| 23 | pub fn spawn_session_reaper(store: Arc<Store>, interval: Duration) { |
| 24 | tokio::spawn(async move { |
| 25 | tokio::time::sleep(interval).await; |
| 26 | |
| 27 | loop { |
| 28 | if let Err(e) = reap_expired_sessions(&store).await { |
| 29 | warn!(error = %e, "SSH session reaper sweep failed"); |
| 30 | } |
| 31 | tokio::time::sleep(interval).await; |
| 32 | } |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | async fn reap_expired_sessions(store: &Store) -> Result<(), String> { |
| 37 | let now_ms = now_ms(); |
no test coverage detected