Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | /** * Room TTL Cleanup Scheduler * Periodically cleans up expired rooms */ import { cleanupExpiredRooms } from './room-manager' // Cleanup interval: run every 5 minutes const CLEANUP_INTERVAL_MS = 5 * 60 * 1000 let cleanupInterval: NodeJS.Timeout | null = null /** * Start the TTL cleanup scheduler * Runs cleanup every 5 minutes */ export function startRoomTTLCleanup() { if (cleanupInterval) { console.log('[Room TTL] Cleanup scheduler already running') return } console.log('[Room TTL] Starting cleanup scheduler (every 5 minutes)') // Run immediately on start cleanupExpiredRooms() .then((count) => { if (count > 0) { console.log(`[Room TTL] Initial cleanup removed ${count} expired rooms`) } }) .catch((error) => { console.error('[Room TTL] Initial cleanup failed:', error) }) // Then run periodically cleanupInterval = setInterval(async () => { try { const count = await cleanupExpiredRooms() if (count > 0) { console.log(`[Room TTL] Cleanup removed ${count} expired rooms`) } } catch (error) { console.error('[Room TTL] Cleanup failed:', error) } }, CLEANUP_INTERVAL_MS) } /** * Stop the TTL cleanup scheduler */ export function stopRoomTTLCleanup() { if (cleanupInterval) { clearInterval(cleanupInterval) cleanupInterval = null console.log('[Room TTL] Cleanup scheduler stopped') } } |