aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-19 16:21:09 +0200
committerChocobozzz <me@florianbigard.com>2018-09-19 16:21:30 +0200
commitf9f899b9f803eb5159a67781f10649a0cf040677 (patch)
tree2c02f33e38b0fdc9401fe5c98d7b148c967c68df /server
parentd9bdd007d7a1368d2a13127ecb5c0a81a18a8c04 (diff)
downloadPeerTube-f9f899b9f803eb5159a67781f10649a0cf040677.tar.gz
PeerTube-f9f899b9f803eb5159a67781f10649a0cf040677.tar.zst
PeerTube-f9f899b9f803eb5159a67781f10649a0cf040677.zip
Add redundancy check interval in config
Diffstat (limited to 'server')
-rw-r--r--server/initializers/checker.ts2
-rw-r--r--server/initializers/constants.ts7
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts18
3 files changed, 15 insertions, 12 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 8b5280848..a54f6155b 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -75,7 +75,7 @@ function checkMissedConfig () {
75 'cache.previews.size', 'admin.email', 75 'cache.previews.size', 'admin.email',
76 'signup.enabled', 'signup.limit', 'signup.requires_email_verification', 76 'signup.enabled', 'signup.limit', 'signup.requires_email_verification',
77 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist', 77 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist',
78 'redundancy.videos.strategies', 78 'redundancy.videos.strategies', 'redundancy.videos.check_interval',
79 'transcoding.enabled', 'transcoding.threads', 79 'transcoding.enabled', 'transcoding.threads',
80 'import.videos.http.enabled', 'import.videos.torrent.enabled', 80 'import.videos.http.enabled', 'import.videos.torrent.enabled',
81 'trending.videos.interval_days', 81 'trending.videos.interval_days',
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 881978753..03424ffb8 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -5,7 +5,7 @@ import { ActivityPubActorType } from '../../shared/models/activitypub'
5import { FollowState } from '../../shared/models/actors' 5import { FollowState } from '../../shared/models/actors'
6import { VideoAbuseState, VideoImportState, VideoPrivacy } from '../../shared/models/videos' 6import { VideoAbuseState, VideoImportState, VideoPrivacy } from '../../shared/models/videos'
7// Do not use barrels, remain constants as independent as possible 7// Do not use barrels, remain constants as independent as possible
8import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' 8import { buildPath, isTestInstance, parseDuration, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' 9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
10import { invert } from 'lodash' 10import { invert } from 'lodash'
11import { CronRepeatOptions, EveryRepeatOptions } from 'bull' 11import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
@@ -139,8 +139,7 @@ let SCHEDULER_INTERVALS_MS = {
139 badActorFollow: 60000 * 60, // 1 hour 139 badActorFollow: 60000 * 60, // 1 hour
140 removeOldJobs: 60000 * 60, // 1 hour 140 removeOldJobs: 60000 * 60, // 1 hour
141 updateVideos: 60000, // 1 minute 141 updateVideos: 60000, // 1 minute
142 youtubeDLUpdate: 60000 * 60 * 24, // 1 day 142 youtubeDLUpdate: 60000 * 60 * 24 // 1 day
143 videosRedundancy: 60000 * 2 // 2 hours
144} 143}
145 144
146// --------------------------------------------------------------------------- 145// ---------------------------------------------------------------------------
@@ -213,6 +212,7 @@ const CONFIG = {
213 }, 212 },
214 REDUNDANCY: { 213 REDUNDANCY: {
215 VIDEOS: { 214 VIDEOS: {
215 CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')),
216 STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies')) 216 STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
217 } 217 }
218 }, 218 },
@@ -651,7 +651,6 @@ if (isTestInstance() === true) {
651 SCHEDULER_INTERVALS_MS.badActorFollow = 10000 651 SCHEDULER_INTERVALS_MS.badActorFollow = 10000
652 SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 652 SCHEDULER_INTERVALS_MS.removeOldJobs = 10000
653 SCHEDULER_INTERVALS_MS.updateVideos = 5000 653 SCHEDULER_INTERVALS_MS.updateVideos = 5000
654 SCHEDULER_INTERVALS_MS.videosRedundancy = 5000
655 REPEAT_JOBS['videos-views'] = { every: 5000 } 654 REPEAT_JOBS['videos-views'] = { every: 5000 }
656 655
657 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 656 REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index 5f9fd9911..960651712 100644
--- a/server/lib/schedulers/videos-redundancy-scheduler.ts
+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts
@@ -18,7 +18,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
18 private static instance: AbstractScheduler 18 private static instance: AbstractScheduler
19 private executing = false 19 private executing = false
20 20
21 protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.videosRedundancy 21 protected schedulerIntervalMs = CONFIG.REDUNDANCY.VIDEOS.CHECK_INTERVAL
22 22
23 private constructor () { 23 private constructor () {
24 super() 24 super()
@@ -50,6 +50,16 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
50 } 50 }
51 } 51 }
52 52
53 await this.removeExpired()
54
55 this.executing = false
56 }
57
58 static get Instance () {
59 return this.instance || (this.instance = new this())
60 }
61
62 private async removeExpired () {
53 const expired = await VideoRedundancyModel.listAllExpired() 63 const expired = await VideoRedundancyModel.listAllExpired()
54 64
55 for (const m of expired) { 65 for (const m of expired) {
@@ -61,12 +71,6 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
61 logger.error('Cannot remove %s video from our redundancy system.', this.buildEntryLogId(m)) 71 logger.error('Cannot remove %s video from our redundancy system.', this.buildEntryLogId(m))
62 } 72 }
63 } 73 }
64
65 this.executing = false
66 }
67
68 static get Instance () {
69 return this.instance || (this.instance = new this())
70 } 74 }
71 75
72 private findVideoToDuplicate (cache: VideosRedundancy) { 76 private findVideoToDuplicate (cache: VideosRedundancy) {