Fix redundancy totalVideos stats
[oweals/peertube.git] / server / lib / schedulers / remove-old-jobs-scheduler.ts
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'
6
7 export class RemoveOldJobsScheduler extends AbstractScheduler {
8
9   private static instance: AbstractScheduler
10
11   protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.removeOldJobs
12
13   private constructor () {
14     super()
15   }
16
17   async execute () {
18     if (!isTestInstance()) logger.info('Removing old jobs (scheduler).')
19
20     JobQueue.Instance.removeOldJobs()
21   }
22
23   static get Instance () {
24     return this.instance || (this.instance = new this())
25   }
26 }