diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-20 16:24:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 16:24:31 +0200 |
commit | 0491173a61aed66205c017e0d7e0503ea316c144 (patch) | |
tree | ce6621597505f9518cfdf0981977d097c63f9fad /server/initializers/constants.ts | |
parent | 8704acf49efc770d73bf07c10468ed8c74d28a83 (diff) | |
parent | 6247b2057b792cea155a1abd9788c363ae7d2cc2 (diff) | |
download | PeerTube-0491173a61aed66205c017e0d7e0503ea316c144.tar.gz PeerTube-0491173a61aed66205c017e0d7e0503ea316c144.tar.zst PeerTube-0491173a61aed66205c017e0d7e0503ea316c144.zip |
Merge branch 'develop' into cli-wrapper
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r-- | server/initializers/constants.ts | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 6b4afbfd8..03424ffb8 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import { IConfig } from 'config' | 1 | import { IConfig } from 'config' |
2 | import { dirname, join } from 'path' | 2 | import { dirname, join } from 'path' |
3 | import { JobType, VideoRateType, VideoRedundancyStrategy, VideoState, VideosRedundancy } from '../../shared/models' | 3 | import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models' |
4 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 4 | 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' |
@@ -66,7 +66,8 @@ const ROUTE_CACHE_LIFETIME = { | |||
66 | }, | 66 | }, |
67 | ACTIVITY_PUB: { | 67 | ACTIVITY_PUB: { |
68 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example | 68 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example |
69 | } | 69 | }, |
70 | STATS: '4 hours' | ||
70 | } | 71 | } |
71 | 72 | ||
72 | // --------------------------------------------------------------------------- | 73 | // --------------------------------------------------------------------------- |
@@ -138,8 +139,7 @@ let SCHEDULER_INTERVALS_MS = { | |||
138 | badActorFollow: 60000 * 60, // 1 hour | 139 | badActorFollow: 60000 * 60, // 1 hour |
139 | removeOldJobs: 60000 * 60, // 1 hour | 140 | removeOldJobs: 60000 * 60, // 1 hour |
140 | updateVideos: 60000, // 1 minute | 141 | updateVideos: 60000, // 1 minute |
141 | youtubeDLUpdate: 60000 * 60 * 24, // 1 day | 142 | youtubeDLUpdate: 60000 * 60 * 24 // 1 day |
142 | videosRedundancy: 60000 * 2 // 2 hours | ||
143 | } | 143 | } |
144 | 144 | ||
145 | // --------------------------------------------------------------------------- | 145 | // --------------------------------------------------------------------------- |
@@ -211,7 +211,10 @@ const CONFIG = { | |||
211 | } | 211 | } |
212 | }, | 212 | }, |
213 | REDUNDANCY: { | 213 | REDUNDANCY: { |
214 | VIDEOS: buildVideosRedundancy(config.get<any[]>('redundancy.videos')) | 214 | VIDEOS: { |
215 | CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')), | ||
216 | STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies')) | ||
217 | } | ||
215 | }, | 218 | }, |
216 | ADMIN: { | 219 | ADMIN: { |
217 | get EMAIL () { return config.get<string>('admin.email') } | 220 | get EMAIL () { return config.get<string>('admin.email') } |
@@ -592,6 +595,10 @@ const CACHE = { | |||
592 | } | 595 | } |
593 | } | 596 | } |
594 | 597 | ||
598 | const MEMOIZE_TTL = { | ||
599 | OVERVIEWS_SAMPLE: 1000 * 3600 * 4 // 4 hours | ||
600 | } | ||
601 | |||
595 | const REDUNDANCY = { | 602 | const REDUNDANCY = { |
596 | VIDEOS: { | 603 | VIDEOS: { |
597 | EXPIRES_AFTER_MS: 48 * 3600 * 1000, // 2 days | 604 | EXPIRES_AFTER_MS: 48 * 3600 * 1000, // 2 days |
@@ -644,7 +651,6 @@ if (isTestInstance() === true) { | |||
644 | SCHEDULER_INTERVALS_MS.badActorFollow = 10000 | 651 | SCHEDULER_INTERVALS_MS.badActorFollow = 10000 |
645 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 | 652 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 |
646 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 | 653 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
647 | SCHEDULER_INTERVALS_MS.videosRedundancy = 5000 | ||
648 | REPEAT_JOBS['videos-views'] = { every: 5000 } | 654 | REPEAT_JOBS['videos-views'] = { every: 5000 } |
649 | 655 | ||
650 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 | 656 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
@@ -654,6 +660,8 @@ if (isTestInstance() === true) { | |||
654 | JOB_ATTEMPTS['email'] = 1 | 660 | JOB_ATTEMPTS['email'] = 1 |
655 | 661 | ||
656 | CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 | 662 | CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 |
663 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 | ||
664 | ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms' | ||
657 | } | 665 | } |
658 | 666 | ||
659 | updateWebserverConfig() | 667 | updateWebserverConfig() |
@@ -708,6 +716,7 @@ export { | |||
708 | VIDEO_ABUSE_STATES, | 716 | VIDEO_ABUSE_STATES, |
709 | JOB_REQUEST_TIMEOUT, | 717 | JOB_REQUEST_TIMEOUT, |
710 | USER_PASSWORD_RESET_LIFETIME, | 718 | USER_PASSWORD_RESET_LIFETIME, |
719 | MEMOIZE_TTL, | ||
711 | USER_EMAIL_VERIFY_LIFETIME, | 720 | USER_EMAIL_VERIFY_LIFETIME, |
712 | IMAGE_MIMETYPE_EXT, | 721 | IMAGE_MIMETYPE_EXT, |
713 | OVERVIEWS, | 722 | OVERVIEWS, |
@@ -741,15 +750,10 @@ function updateWebserverConfig () { | |||
741 | CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) | 750 | CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) |
742 | } | 751 | } |
743 | 752 | ||
744 | function buildVideosRedundancy (objs: { strategy: VideoRedundancyStrategy, size: string }[]): VideosRedundancy[] { | 753 | function buildVideosRedundancy (objs: VideosRedundancy[]): VideosRedundancy[] { |
745 | if (!objs) return [] | 754 | if (!objs) return [] |
746 | 755 | ||
747 | return objs.map(obj => { | 756 | return objs.map(obj => Object.assign(obj, { size: bytes.parse(obj.size) })) |
748 | return { | ||
749 | strategy: obj.strategy, | ||
750 | size: bytes.parse(obj.size) | ||
751 | } | ||
752 | }) | ||
753 | } | 757 | } |
754 | 758 | ||
755 | function buildLanguages () { | 759 | function buildLanguages () { |