diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index b4a42af..8b870dc 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -94,7 +94,7 @@ async fn main() -> Result<()> { | |||
| 94 | sync_manager.run().await; | 94 | sync_manager.run().await; |
| 95 | }); | 95 | }); |
| 96 | 96 | ||
| 97 | // Spawn background cleanup task | 97 | // Spawn background cleanup task for purgatory entries (60s interval) |
| 98 | let cleanup_purgatory = purgatory.clone(); | 98 | let cleanup_purgatory = purgatory.clone(); |
| 99 | tokio::spawn(async move { | 99 | tokio::spawn(async move { |
| 100 | let mut interval = tokio::time::interval(Duration::from_secs(60)); | 100 | let mut interval = tokio::time::interval(Duration::from_secs(60)); |
| @@ -111,6 +111,26 @@ async fn main() -> Result<()> { | |||
| 111 | }); | 111 | }); |
| 112 | info!("Purgatory cleanup task started (60s interval)"); | 112 | info!("Purgatory cleanup task started (60s interval)"); |
| 113 | 113 | ||
| 114 | // Spawn daily cleanup task for old expired event records (prevent unbounded growth) | ||
| 115 | let expired_cleanup_purgatory = purgatory.clone(); | ||
| 116 | tokio::spawn(async move { | ||
| 117 | // Run immediately on startup, then every 24 hours | ||
| 118 | let mut interval = tokio::time::interval(Duration::from_secs(24 * 3600)); | ||
| 119 | loop { | ||
| 120 | interval.tick().await; | ||
| 121 | // Remove expired event records older than 7 days | ||
| 122 | let removed = expired_cleanup_purgatory | ||
| 123 | .cleanup_expired_events(Duration::from_secs(7 * 24 * 3600)); | ||
| 124 | if removed > 0 { | ||
| 125 | info!( | ||
| 126 | "Expired event cleanup: removed {} old expired event records (>7 days)", | ||
| 127 | removed | ||
| 128 | ); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | }); | ||
| 132 | info!("Expired event cleanup task started (24h interval, keeps 7 days)"); | ||
| 133 | |||
| 114 | // Start purgatory sync loop for background git data fetching | 134 | // Start purgatory sync loop for background git data fetching |
| 115 | let sync_ctx = Arc::new(RealSyncContext::new( | 135 | let sync_ctx = Arc::new(RealSyncContext::new( |
| 116 | purgatory.clone(), | 136 | purgatory.clone(), |