aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/lib/schedulers/remove-old-jobs-scheduler.ts
blob: a29a6b80091bf1bc811acf2636f17c2e301a91fb (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                         
                                             

                                                        
                                                           




                                                               

                                                                      




                          
                                                                        
 






                                                        
import { isTestInstance } from '../../helpers/core-utils'
import { logger } from '../../helpers/logger'
import { JobQueue } from '../job-queue'
import { AbstractScheduler } from './abstract-scheduler'
import { SCHEDULER_INTERVALS_MS } from '../../initializers'

export class RemoveOldJobsScheduler extends AbstractScheduler {

  private static instance: AbstractScheduler

  protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.removeOldJobs

  private constructor () {
    super()
  }

  async execute () {
    if (!isTestInstance()) logger.info('Removing old jobs (scheduler).')

    JobQueue.Instance.removeOldJobs()
  }

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