2022-07-06 15:44:14 +02:00
|
|
|
import { isTestOrDevInstance } from '../../helpers/core-utils'
|
2018-02-27 11:08:59 +01:00
|
|
|
import { logger } from '../../helpers/logger'
|
2022-07-06 15:44:14 +02:00
|
|
|
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
|
2018-01-25 15:05:18 +01:00
|
|
|
import { JobQueue } from '../job-queue'
|
|
|
|
import { AbstractScheduler } from './abstract-scheduler'
|
|
|
|
|
2022-11-23 17:13:01 +01:00
|
|
|
// FIXME: delete this scheduler in a few versions (introduced in 5.0)
|
|
|
|
// We introduced job removal directly using bullmq option but we still need to delete old jobs
|
2018-01-25 15:05:18 +01:00
|
|
|
export class RemoveOldJobsScheduler extends AbstractScheduler {
|
|
|
|
|
|
|
|
private static instance: AbstractScheduler
|
|
|
|
|
2021-10-22 10:28:00 +02:00
|
|
|
protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS
|
2018-06-14 18:06:56 +02:00
|
|
|
|
2018-01-25 15:05:18 +01:00
|
|
|
private constructor () {
|
|
|
|
super()
|
|
|
|
}
|
|
|
|
|
2018-12-20 14:31:11 +01:00
|
|
|
protected internalExecute () {
|
2022-07-06 15:44:14 +02:00
|
|
|
if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.')
|
2018-02-27 11:08:59 +01:00
|
|
|
|
2018-12-20 14:31:11 +01:00
|
|
|
return JobQueue.Instance.removeOldJobs()
|
2018-01-25 15:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static get Instance () {
|
|
|
|
return this.instance || (this.instance = new this())
|
|
|
|
}
|
|
|
|
}
|