aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/constants.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r--server/initializers/constants.ts53
1 files changed, 47 insertions, 6 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 3aa979668..069d9b2e8 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -8,6 +8,7 @@ import { VideoPrivacy } from '../../shared/models/videos'
8import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' 8import { buildPath, isTestInstance, 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 { VideoImportState } from '../../shared/models/videos/video-import-state.enum'
11 12
12// Use a variable to reload the configuration if we need 13// Use a variable to reload the configuration if we need
13let config: IConfig = require('config') 14let config: IConfig = require('config')
@@ -36,6 +37,7 @@ const SORTABLE_COLUMNS = {
36 VIDEO_ABUSES: [ 'id', 'createdAt' ], 37 VIDEO_ABUSES: [ 'id', 'createdAt' ],
37 VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ], 38 VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
38 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes' ], 39 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes' ],
40 VIDEO_IMPORTS: [ 'createdAt' ],
39 VIDEO_COMMENT_THREADS: [ 'createdAt' ], 41 VIDEO_COMMENT_THREADS: [ 'createdAt' ],
40 BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], 42 BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
41 FOLLOWERS: [ 'createdAt' ], 43 FOLLOWERS: [ 'createdAt' ],
@@ -85,6 +87,7 @@ const JOB_ATTEMPTS: { [ id in JobType ]: number } = {
85 'activitypub-follow': 5, 87 'activitypub-follow': 5,
86 'video-file-import': 1, 88 'video-file-import': 1,
87 'video-file': 1, 89 'video-file': 1,
90 'video-import': 1,
88 'email': 5 91 'email': 5
89} 92}
90const JOB_CONCURRENCY: { [ id in JobType ]: number } = { 93const JOB_CONCURRENCY: { [ id in JobType ]: number } = {
@@ -94,18 +97,29 @@ const JOB_CONCURRENCY: { [ id in JobType ]: number } = {
94 'activitypub-follow': 3, 97 'activitypub-follow': 3,
95 'video-file-import': 1, 98 'video-file-import': 1,
96 'video-file': 1, 99 'video-file': 1,
100 'video-import': 1,
97 'email': 5 101 'email': 5
98} 102}
103const JOB_TTL: { [ id in JobType ]: number } = {
104 'activitypub-http-broadcast': 60000 * 10, // 10 minutes
105 'activitypub-http-unicast': 60000 * 10, // 10 minutes
106 'activitypub-http-fetcher': 60000 * 10, // 10 minutes
107 'activitypub-follow': 60000 * 10, // 10 minutes
108 'video-file-import': 1000 * 3600, // 1 hour
109 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long
110 'video-import': 1000 * 3600 * 5, // 5 hours
111 'email': 60000 * 10 // 10 minutes
112}
99const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job 113const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job
100const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds 114const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds
101const JOB_REQUEST_TTL = 60000 * 10 // 10 minutes
102const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days 115const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days
103 116
104// 1 hour 117// 1 hour
105let SCHEDULER_INTERVALS_MS = { 118let SCHEDULER_INTERVALS_MS = {
106 badActorFollow: 60000 * 60, // 1 hour 119 badActorFollow: 60000 * 60, // 1 hour
107 removeOldJobs: 60000 * 60, // 1 hour 120 removeOldJobs: 60000 * 60, // 1 hour
108 updateVideos: 60000 // 1 minute 121 updateVideos: 60000, // 1 minute
122 youtubeDLUpdate: 60000 * 60 * 24 // 1 day
109} 123}
110 124
111// --------------------------------------------------------------------------- 125// ---------------------------------------------------------------------------
@@ -121,7 +135,10 @@ const CONFIG = {
121 HOSTNAME: config.get<string>('database.hostname'), 135 HOSTNAME: config.get<string>('database.hostname'),
122 PORT: config.get<number>('database.port'), 136 PORT: config.get<number>('database.port'),
123 USERNAME: config.get<string>('database.username'), 137 USERNAME: config.get<string>('database.username'),
124 PASSWORD: config.get<string>('database.password') 138 PASSWORD: config.get<string>('database.password'),
139 POOL: {
140 MAX: config.get<number>('database.pool.max')
141 }
125 }, 142 },
126 REDIS: { 143 REDIS: {
127 HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null, 144 HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null,
@@ -189,6 +206,13 @@ const CONFIG = {
189 get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') } 206 get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') }
190 } 207 }
191 }, 208 },
209 IMPORT: {
210 VIDEOS: {
211 HTTP: {
212 get ENABLED () { return config.get<boolean>('import.videos.http.enabled') }
213 }
214 }
215 },
192 CACHE: { 216 CACHE: {
193 PREVIEWS: { 217 PREVIEWS: {
194 get SIZE () { return config.get<number>('cache.previews.size') } 218 get SIZE () { return config.get<number>('cache.previews.size') }
@@ -245,6 +269,9 @@ const CONSTRAINTS_FIELDS = {
245 } 269 }
246 } 270 }
247 }, 271 },
272 VIDEO_IMPORTS: {
273 URL: { min: 3, max: 2000 } // Length
274 },
248 VIDEOS: { 275 VIDEOS: {
249 NAME: { min: 3, max: 120 }, // Length 276 NAME: { min: 3, max: 120 }, // Length
250 LANGUAGE: { min: 1, max: 10 }, // Length 277 LANGUAGE: { min: 1, max: 10 }, // Length
@@ -259,7 +286,7 @@ const CONSTRAINTS_FIELDS = {
259 }, 286 },
260 EXTNAME: [ '.mp4', '.ogv', '.webm' ], 287 EXTNAME: [ '.mp4', '.ogv', '.webm' ],
261 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 288 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2
262 DURATION: { min: 1 }, // Number 289 DURATION: { min: 0 }, // Number
263 TAGS: { min: 0, max: 5 }, // Number of total tags 290 TAGS: { min: 0, max: 5 }, // Number of total tags
264 TAG: { min: 2, max: 30 }, // Length 291 TAG: { min: 2, max: 30 }, // Length
265 THUMBNAIL: { min: 2, max: 30 }, 292 THUMBNAIL: { min: 2, max: 30 },
@@ -313,6 +340,11 @@ const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = {
313 DISLIKE: 'dislike' 340 DISLIKE: 'dislike'
314} 341}
315 342
343const FFMPEG_NICE: { [ id: string ]: number } = {
344 THUMBNAIL: 2, // 2 just for don't blocking servers
345 TRANSCODING: 15
346}
347
316const VIDEO_CATEGORIES = { 348const VIDEO_CATEGORIES = {
317 1: 'Music', 349 1: 'Music',
318 2: 'Films', 350 2: 'Films',
@@ -355,7 +387,14 @@ const VIDEO_PRIVACIES = {
355 387
356const VIDEO_STATES = { 388const VIDEO_STATES = {
357 [VideoState.PUBLISHED]: 'Published', 389 [VideoState.PUBLISHED]: 'Published',
358 [VideoState.TO_TRANSCODE]: 'To transcode' 390 [VideoState.TO_TRANSCODE]: 'To transcode',
391 [VideoState.TO_IMPORT]: 'To import'
392}
393
394const VIDEO_IMPORT_STATES = {
395 [VideoImportState.FAILED]: 'Failed',
396 [VideoImportState.PENDING]: 'Pending',
397 [VideoImportState.SUCCESS]: 'Success'
359} 398}
360 399
361const VIDEO_MIMETYPE_EXT = { 400const VIDEO_MIMETYPE_EXT = {
@@ -553,6 +592,7 @@ export {
553 ROUTE_CACHE_LIFETIME, 592 ROUTE_CACHE_LIFETIME,
554 SORTABLE_COLUMNS, 593 SORTABLE_COLUMNS,
555 FEEDS, 594 FEEDS,
595 JOB_TTL,
556 NSFW_POLICY_TYPES, 596 NSFW_POLICY_TYPES,
557 STATIC_MAX_AGE, 597 STATIC_MAX_AGE,
558 STATIC_PATHS, 598 STATIC_PATHS,
@@ -567,8 +607,8 @@ export {
567 VIDEO_RATE_TYPES, 607 VIDEO_RATE_TYPES,
568 VIDEO_MIMETYPE_EXT, 608 VIDEO_MIMETYPE_EXT,
569 VIDEO_TRANSCODING_FPS, 609 VIDEO_TRANSCODING_FPS,
610 FFMPEG_NICE,
570 JOB_REQUEST_TIMEOUT, 611 JOB_REQUEST_TIMEOUT,
571 JOB_REQUEST_TTL,
572 USER_PASSWORD_RESET_LIFETIME, 612 USER_PASSWORD_RESET_LIFETIME,
573 IMAGE_MIMETYPE_EXT, 613 IMAGE_MIMETYPE_EXT,
574 SCHEDULER_INTERVALS_MS, 614 SCHEDULER_INTERVALS_MS,
@@ -576,6 +616,7 @@ export {
576 RATES_LIMIT, 616 RATES_LIMIT,
577 VIDEO_EXT_MIMETYPE, 617 VIDEO_EXT_MIMETYPE,
578 JOB_COMPLETED_LIFETIME, 618 JOB_COMPLETED_LIFETIME,
619 VIDEO_IMPORT_STATES,
579 VIDEO_VIEW_LIFETIME, 620 VIDEO_VIEW_LIFETIME,
580 buildLanguages 621 buildLanguages
581} 622}