aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/default.yaml1
-rw-r--r--config/production.yaml.example1
-rw-r--r--config/test.yaml1
-rw-r--r--server/initializers/checker.ts2
-rw-r--r--server/initializers/constants.ts7
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts18
6 files changed, 18 insertions, 12 deletions
diff --git a/config/default.yaml b/config/default.yaml
index 00eeaea8c..fa1fb628a 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -71,6 +71,7 @@ trending:
71# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following 71# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following
72redundancy: 72redundancy:
73 videos: 73 videos:
74 check_interval: '1 hour' # How often you want to check new videos to cache
74 strategies: 75 strategies:
75# - 76# -
76# size: '10GB' 77# size: '10GB'
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 28770e480..4d8752206 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -72,6 +72,7 @@ trending:
72# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following 72# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following
73redundancy: 73redundancy:
74 videos: 74 videos:
75 check_interval: '1 hour' # How often you want to check new videos to cache
75 strategies: 76 strategies:
76# - 77# -
77# size: '10GB' 78# size: '10GB'
diff --git a/config/test.yaml b/config/test.yaml
index d36d90bbd..ad94b00cd 100644
--- a/config/test.yaml
+++ b/config/test.yaml
@@ -23,6 +23,7 @@ log:
23 23
24redundancy: 24redundancy:
25 videos: 25 videos:
26 check_interval: '5 seconds'
26 strategies: 27 strategies:
27 - 28 -
28 size: '10MB' 29 size: '10MB'
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) {