diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-19 16:21:09 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-19 16:21:30 +0200 |
commit | f9f899b9f803eb5159a67781f10649a0cf040677 (patch) | |
tree | 2c02f33e38b0fdc9401fe5c98d7b148c967c68df | |
parent | d9bdd007d7a1368d2a13127ecb5c0a81a18a8c04 (diff) | |
download | PeerTube-f9f899b9f803eb5159a67781f10649a0cf040677.tar.gz PeerTube-f9f899b9f803eb5159a67781f10649a0cf040677.tar.zst PeerTube-f9f899b9f803eb5159a67781f10649a0cf040677.zip |
Add redundancy check interval in config
-rw-r--r-- | config/default.yaml | 1 | ||||
-rw-r--r-- | config/production.yaml.example | 1 | ||||
-rw-r--r-- | config/test.yaml | 1 | ||||
-rw-r--r-- | server/initializers/checker.ts | 2 | ||||
-rw-r--r-- | server/initializers/constants.ts | 7 | ||||
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 18 |
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 |
72 | redundancy: | 72 | redundancy: |
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 |
73 | redundancy: | 73 | redundancy: |
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 | ||
24 | redundancy: | 24 | redundancy: |
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' | |||
5 | import { FollowState } from '../../shared/models/actors' | 5 | import { FollowState } from '../../shared/models/actors' |
6 | import { VideoAbuseState, VideoImportState, VideoPrivacy } from '../../shared/models/videos' | 6 | import { 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 |
8 | import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' | 8 | import { buildPath, isTestInstance, parseDuration, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
9 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 9 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
10 | import { invert } from 'lodash' | 10 | import { invert } from 'lodash' |
11 | import { CronRepeatOptions, EveryRepeatOptions } from 'bull' | 11 | import { 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) { |