aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/schedulers/remove-old-jobs-scheduler.ts
blob: 879846999dc9383b6d27fa57238b646eabdf2097 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { isTestOrDevInstance } from '../../helpers/core-utils'
import { logger } from '../../helpers/logger'
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
import { JobQueue } from '../job-queue'
import { AbstractScheduler } from './abstract-scheduler'

export class RemoveOldJobsScheduler extends AbstractScheduler {

  private static instance: AbstractScheduler

  protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS

  private constructor () {
    super()
  }

  protected internalExecute () {
    if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.')

    return JobQueue.Instance.removeOldJobs()
  }

  static get Instance () {
    return this.instance || (this.instance = new this())
  }
}