diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-11 15:38:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-11 15:38:53 +0200 |
commit | 8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98 (patch) | |
tree | e04f1da52f9377cf6ce820425c0de6e57ab57fc6 /server/initializers | |
parent | 76062d9f96e06a23a2efc8a727ea9c5394d21466 (diff) | |
download | PeerTube-8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98.tar.gz PeerTube-8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98.tar.zst PeerTube-8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98.zip |
Add ability to limit videos history size
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/config.ts | 11 | ||||
-rw-r--r-- | server/initializers/constants.ts | 9 |
2 files changed, 13 insertions, 7 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 8dd62cba8..1f374dea9 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -2,7 +2,7 @@ import { IConfig } from 'config' | |||
2 | import { dirname, join } from 'path' | 2 | import { dirname, join } from 'path' |
3 | import { VideosRedundancy } from '../../shared/models' | 3 | import { VideosRedundancy } from '../../shared/models' |
4 | // Do not use barrels, remain constants as independent as possible | 4 | // Do not use barrels, remain constants as independent as possible |
5 | import { buildPath, parseBytes, parseDuration, root } from '../helpers/core-utils' | 5 | import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' |
6 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 6 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
7 | import * as bytes from 'bytes' | 7 | import * as bytes from 'bytes' |
8 | 8 | ||
@@ -80,7 +80,7 @@ const CONFIG = { | |||
80 | }, | 80 | }, |
81 | REDUNDANCY: { | 81 | REDUNDANCY: { |
82 | VIDEOS: { | 82 | VIDEOS: { |
83 | CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')), | 83 | CHECK_INTERVAL: parseDurationToMs(config.get<string>('redundancy.videos.check_interval')), |
84 | STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies')) | 84 | STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies')) |
85 | } | 85 | } |
86 | }, | 86 | }, |
@@ -94,6 +94,11 @@ const CONFIG = { | |||
94 | PRIVATE: config.get<boolean>('tracker.private'), | 94 | PRIVATE: config.get<boolean>('tracker.private'), |
95 | REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces') | 95 | REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces') |
96 | }, | 96 | }, |
97 | HISTORY: { | ||
98 | VIDEOS: { | ||
99 | MAX_AGE: parseDurationToMs(config.get('history.videos.max_age')) | ||
100 | } | ||
101 | }, | ||
97 | ADMIN: { | 102 | ADMIN: { |
98 | get EMAIL () { return config.get<string>('admin.email') } | 103 | get EMAIL () { return config.get<string>('admin.email') } |
99 | }, | 104 | }, |
@@ -216,7 +221,7 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancy[] { | |||
216 | 221 | ||
217 | return objs.map(obj => { | 222 | return objs.map(obj => { |
218 | return Object.assign({}, obj, { | 223 | return Object.assign({}, obj, { |
219 | minLifetime: parseDuration(obj.min_lifetime), | 224 | minLifetime: parseDurationToMs(obj.min_lifetime), |
220 | size: bytes.parse(obj.size), | 225 | size: bytes.parse(obj.size), |
221 | minViews: obj.min_views | 226 | minViews: obj.min_views |
222 | }) | 227 | }) |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index a0609d7cd..f008cd291 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -158,12 +158,12 @@ const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds | |||
158 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days | 158 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days |
159 | const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour | 159 | const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour |
160 | 160 | ||
161 | // 1 hour | 161 | const SCHEDULER_INTERVALS_MS = { |
162 | let SCHEDULER_INTERVALS_MS = { | ||
163 | actorFollowScores: 60000 * 60, // 1 hour | 162 | actorFollowScores: 60000 * 60, // 1 hour |
164 | removeOldJobs: 60000 * 60, // 1 hour | 163 | removeOldJobs: 60000 * 60, // 1 hour |
165 | updateVideos: 60000, // 1 minute | 164 | updateVideos: 60000, // 1 minute |
166 | youtubeDLUpdate: 60000 * 60 * 24 // 1 day | 165 | youtubeDLUpdate: 60000 * 60 * 24, // 1 day |
166 | removeOldHistory: 60000 * 60 * 24 // 1 day | ||
167 | } | 167 | } |
168 | 168 | ||
169 | // --------------------------------------------------------------------------- | 169 | // --------------------------------------------------------------------------- |
@@ -591,6 +591,7 @@ if (isTestInstance() === true) { | |||
591 | 591 | ||
592 | SCHEDULER_INTERVALS_MS.actorFollowScores = 1000 | 592 | SCHEDULER_INTERVALS_MS.actorFollowScores = 1000 |
593 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 | 593 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 |
594 | SCHEDULER_INTERVALS_MS.removeOldHistory = 5000 | ||
594 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 | 595 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
595 | REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } | 596 | REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } |
596 | 597 | ||
@@ -734,7 +735,7 @@ function buildVideosExtname () { | |||
734 | } | 735 | } |
735 | 736 | ||
736 | function loadLanguages () { | 737 | function loadLanguages () { |
737 | VIDEO_LANGUAGES = buildLanguages() | 738 | Object.assign(VIDEO_LANGUAGES, buildLanguages()) |
738 | } | 739 | } |
739 | 740 | ||
740 | function buildLanguages () { | 741 | function buildLanguages () { |