remove-old-jobs-scheduler.ts 747 B

1234567891011121314151617181920212223242526
  1. import { isTestInstance } from '../../helpers/core-utils'
  2. import { logger } from '../../helpers/logger'
  3. import { JobQueue } from '../job-queue'
  4. import { AbstractScheduler } from './abstract-scheduler'
  5. import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
  6. export class RemoveOldJobsScheduler extends AbstractScheduler {
  7. private static instance: AbstractScheduler
  8. protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.removeOldJobs
  9. private constructor () {
  10. super()
  11. }
  12. protected internalExecute () {
  13. if (!isTestInstance()) logger.info('Removing old jobs in scheduler.')
  14. return JobQueue.Instance.removeOldJobs()
  15. }
  16. static get Instance () {
  17. return this.instance || (this.instance = new this())
  18. }
  19. }