]>
Commit | Line | Data |
---|---|---|
9452d4fd | 1 | import { isTestOrDevInstance } from '../../helpers/core-utils' |
ea99d15f | 2 | import { logger } from '../../helpers/logger' |
9452d4fd | 3 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
94a5ff8a C |
4 | import { JobQueue } from '../job-queue' |
5 | import { AbstractScheduler } from './abstract-scheduler' | |
6 | ||
c3b21b68 C |
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 | |
94a5ff8a C |
9 | export class RemoveOldJobsScheduler extends AbstractScheduler { |
10 | ||
11 | private static instance: AbstractScheduler | |
12 | ||
61953742 | 13 | protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS |
2baea0c7 | 14 | |
94a5ff8a C |
15 | private constructor () { |
16 | super() | |
17 | } | |
18 | ||
2f5c6b2f | 19 | protected internalExecute () { |
9452d4fd | 20 | if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.') |
ea99d15f | 21 | |
2f5c6b2f | 22 | return JobQueue.Instance.removeOldJobs() |
94a5ff8a C |
23 | } |
24 | ||
25 | static get Instance () { | |
26 | return this.instance || (this.instance = new this()) | |
27 | } | |
28 | } |