From f64f200e88eafd496f49ef9de28c704eeae2c007 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 8 Apr 2025 09:54:15 +0200 Subject: [PATCH] backend: Remove room garbage collector and related cleanup timers from TaskSchedulerService --- .../src/services/task-scheduler.service.ts | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/backend/src/services/task-scheduler.service.ts b/backend/src/services/task-scheduler.service.ts index e0fd198..0ce13ca 100644 --- a/backend/src/services/task-scheduler.service.ts +++ b/backend/src/services/task-scheduler.service.ts @@ -18,9 +18,6 @@ export interface IScheduledTask { @injectable() export class TaskSchedulerService { - protected roomGarbageCollectorJob: CronJob | null = null; - private recordingCleanupTimers: Map = new Map(); - private taskRegistry: IScheduledTask[] = []; private scheduledTasks = new Map(); private started = false; @@ -39,44 +36,6 @@ export class TaskSchedulerService { }); } - /** - * Starts the room garbage collector which runs a specified callback function every hour. - * The garbage collector acquires a lock to ensure that only one instance runs at a time. - * If a lock cannot be acquired, the garbage collection is skipped for that hour. - * - * @param callbackFn - The callback function to be executed for garbage collection. - * @returns A promise that resolves when the garbage collector has been successfully started. - */ - async startRoomGarbageCollector(callbackFn: () => Promise): Promise { - // Stop the existing job if it exists - if (this.roomGarbageCollectorJob) { - this.roomGarbageCollectorJob.stop(); - this.roomGarbageCollectorJob = null; - } - - // Create a cron job to run every hour - this.roomGarbageCollectorJob = new CronJob('0 * * * *', async () => { - try { - const lock = await this.mutexService.acquire(MeetLock.getRoomGarbageCollectorLock(), ms('59m')); - - if (!lock) { - this.logger.debug('Failed to acquire lock for room garbage collection. Skipping.'); - return; - } - - this.logger.debug('Lock acquired for room garbage collection.'); - - await callbackFn(); - } catch (error) { - this.logger.error('Error running room garbage collection:', error); - } - }); - - // Start the job - this.logger.debug('Starting room garbage collector'); - this.roomGarbageCollectorJob.start(); - } - /** * Registers a new task to be scheduled. * If the task is already registered, it will not be added again.