backend: Add CRON_JOB_MIN_LOCK_TTL to internal config and use it in task scheduler
This commit is contained in:
parent
cdc55d25ba
commit
dbef4f6e21
@ -28,6 +28,7 @@ const INTERNAL_CONFIG = {
|
||||
RECORDING_STARTED_TIMEOUT: '30s' as StringValue, // Timeout for recording start
|
||||
RECORDING_LOCK_GC_INTERVAL: '30m' as StringValue, // Garbage collection interval for recording locks
|
||||
|
||||
CRON_JOB_MIN_LOCK_TTL: '59s' as StringValue, // Minimum TTL for cron job locks
|
||||
// Additional intervals
|
||||
MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE: '1h' as StringValue
|
||||
};
|
||||
|
||||
@ -5,6 +5,7 @@ import { CronJob } from 'cron';
|
||||
import { MutexService } from './mutex.service.js';
|
||||
import { MeetLock } from '../helpers/redis.helper.js';
|
||||
import ms from 'ms';
|
||||
import INTERNAL_CONFIG from '../config/internal-config.js';
|
||||
|
||||
export type TaskType = 'cron' | 'timeout';
|
||||
|
||||
@ -72,7 +73,7 @@ export class TaskSchedulerService {
|
||||
if (type === 'cron') {
|
||||
this.logger.debug(`Scheduling cron task "${name}" with schedule "${scheduleOrDelay}"`);
|
||||
const cronExpression = this.msStringToCronExpression(scheduleOrDelay);
|
||||
const lockDuration = Math.max(ms(scheduleOrDelay) - ms('1m'), ms('59s'));
|
||||
const lockDuration = Math.max(ms(scheduleOrDelay) - ms('1m'), ms(INTERNAL_CONFIG.CRON_JOB_MIN_LOCK_TTL));
|
||||
|
||||
const job = new CronJob(cronExpression, async () => {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user