]>
Commit | Line | Data |
---|---|---|
1 | import { isTestOrDevInstance } from '../../helpers/core-utils' | |
2 | import { logger } from '../../helpers/logger' | |
3 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | |
4 | import { JobQueue } from '../job-queue' | |
5 | import { AbstractScheduler } from './abstract-scheduler' | |
6 | ||
7 | // FIXME: delete this scheduler in a few versions (introduced in 5.0) | |
8 | // We introduced job removal directly using bullmq option but we still need to delete old jobs | |
9 | export class RemoveOldJobsScheduler extends AbstractScheduler { | |
10 | ||
11 | private static instance: AbstractScheduler | |
12 | ||
13 | protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS | |
14 | ||
15 | private constructor () { | |
16 | super() | |
17 | } | |
18 | ||
19 | protected internalExecute () { | |
20 | if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.') | |
21 | ||
22 | return JobQueue.Instance.removeOldJobs() | |
23 | } | |
24 | ||
25 | static get Instance () { | |
26 | return this.instance || (this.instance = new this()) | |
27 | } | |
28 | } |