2018-02-27 06:46:56 -06:00
|
|
|
import { isTestInstance } from '../../helpers/core-utils'
|
2018-02-27 04:08:59 -06:00
|
|
|
import { logger } from '../../helpers/logger'
|
2018-01-25 08:05:18 -06:00
|
|
|
import { JobQueue } from '../job-queue'
|
|
|
|
import { AbstractScheduler } from './abstract-scheduler'
|
2018-06-14 11:06:56 -05:00
|
|
|
import { SCHEDULER_INTERVALS_MS } from '../../initializers'
|
2018-01-25 08:05:18 -06:00
|
|
|
|
|
|
|
export class RemoveOldJobsScheduler extends AbstractScheduler {
|
|
|
|
|
|
|
|
private static instance: AbstractScheduler
|
|
|
|
|
2018-06-14 11:06:56 -05:00
|
|
|
protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.removeOldJobs
|
|
|
|
|
2018-01-25 08:05:18 -06:00
|
|
|
private constructor () {
|
|
|
|
super()
|
|
|
|
}
|
|
|
|
|
|
|
|
async execute () {
|
2018-02-27 06:46:56 -06:00
|
|
|
if (!isTestInstance()) logger.info('Removing old jobs (scheduler).')
|
2018-02-27 04:08:59 -06:00
|
|
|
|
2018-01-25 08:05:18 -06:00
|
|
|
JobQueue.Instance.removeOldJobs()
|
|
|
|
}
|
|
|
|
|
|
|
|
static get Instance () {
|
|
|
|
return this.instance || (this.instance = new this())
|
|
|
|
}
|
|
|
|
}
|