diff options
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/checker-before-init.ts | 8 | ||||
-rw-r--r-- | server/initializers/config.ts | 34 | ||||
-rw-r--r-- | server/initializers/constants.ts | 28 | ||||
-rw-r--r-- | server/initializers/installer.ts | 3 | ||||
-rw-r--r-- | server/initializers/migrations/0080-video-channels.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0345-video-playlists.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0560-user-feed-token.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0675-p2p-enabled.ts | 21 | ||||
-rw-r--r-- | server/initializers/migrator.ts | 2 |
9 files changed, 83 insertions, 19 deletions
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 51c396548..458005b98 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -33,6 +33,8 @@ function checkMissedConfig () { | |||
33 | 'transcoding.resolutions.2160p', | 33 | 'transcoding.resolutions.2160p', |
34 | 'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'auto_blacklist.videos.of_users.enabled', | 34 | 'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'auto_blacklist.videos.of_users.enabled', |
35 | 'trending.videos.interval_days', | 35 | 'trending.videos.interval_days', |
36 | 'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth', | ||
37 | 'defaults.publish.download_enabled', 'defaults.publish.comments_enabled', 'defaults.publish.privacy', 'defaults.publish.licence', | ||
36 | 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', | 38 | 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', |
37 | 'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt', | 39 | 'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt', |
38 | 'services.twitter.username', 'services.twitter.whitelisted', | 40 | 'services.twitter.username', 'services.twitter.whitelisted', |
@@ -115,7 +117,11 @@ function checkNodeVersion () { | |||
115 | logger.debug('Checking NodeJS version %s.', v) | 117 | logger.debug('Checking NodeJS version %s.', v) |
116 | 118 | ||
117 | if (major <= 10) { | 119 | if (major <= 10) { |
118 | logger.warn('Your NodeJS version %s is deprecated. Please upgrade.', v) | 120 | throw new Error('Your NodeJS version ' + v + ' is not supported. Please upgrade.') |
121 | } | ||
122 | |||
123 | if (major <= 12) { | ||
124 | logger.warn('Your NodeJS version ' + v + ' is deprecated. Please upgrade.') | ||
119 | } | 125 | } |
120 | } | 126 | } |
121 | 127 | ||
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index dadda2a77..fb6f7ae62 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import bytes from 'bytes' | 1 | import bytes from 'bytes' |
2 | import { IConfig } from 'config' | 2 | import { IConfig } from 'config' |
3 | import decache from 'decache' | ||
4 | import { dirname, join } from 'path' | 3 | import { dirname, join } from 'path' |
4 | import { decacheModule } from '@server/helpers/decache' | ||
5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | 5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' |
6 | import { BroadcastMessageLevel } from '@shared/models/server' | 6 | import { BroadcastMessageLevel } from '@shared/models/server' |
7 | import { VideosRedundancyStrategy } from '../../shared/models' | 7 | import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models' |
8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
9 | import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' | 9 | import { buildPath, root } from '../../shared/core-utils' |
10 | import { parseBytes, parseDurationToMs } from '../helpers/core-utils' | ||
10 | 11 | ||
11 | // Use a variable to reload the configuration if we need | 12 | // Use a variable to reload the configuration if we need |
12 | let config: IConfig = require('config') | 13 | let config: IConfig = require('config') |
@@ -63,6 +64,28 @@ const CONFIG = { | |||
63 | MINIATURE: { | 64 | MINIATURE: { |
64 | get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') } | 65 | get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') } |
65 | } | 66 | } |
67 | }, | ||
68 | MENU: { | ||
69 | LOGIN: { | ||
70 | get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () { return config.get<boolean>('client.menu.login.redirect_on_single_external_auth') } | ||
71 | } | ||
72 | } | ||
73 | }, | ||
74 | |||
75 | DEFAULTS: { | ||
76 | PUBLISH: { | ||
77 | DOWNLOAD_ENABLED: config.get<boolean>('defaults.publish.download_enabled'), | ||
78 | COMMENTS_ENABLED: config.get<boolean>('defaults.publish.comments_enabled'), | ||
79 | PRIVACY: config.get<VideoPrivacy>('defaults.publish.privacy'), | ||
80 | LICENCE: config.get<number>('defaults.publish.licence') | ||
81 | }, | ||
82 | P2P: { | ||
83 | WEBAPP: { | ||
84 | ENABLED: config.get<boolean>('defaults.p2p.webapp.enabled') | ||
85 | }, | ||
86 | EMBED: { | ||
87 | ENABLED: config.get<boolean>('defaults.p2p.embed.enabled') | ||
88 | } | ||
66 | } | 89 | } |
67 | }, | 90 | }, |
68 | 91 | ||
@@ -310,7 +333,8 @@ const CONFIG = { | |||
310 | 333 | ||
311 | YOUTUBE_DL_RELEASE: { | 334 | YOUTUBE_DL_RELEASE: { |
312 | get URL () { return config.get<string>('import.videos.http.youtube_dl_release.url') }, | 335 | get URL () { return config.get<string>('import.videos.http.youtube_dl_release.url') }, |
313 | get NAME () { return config.get<string>('import.videos.http.youtube_dl_release.name') } | 336 | get NAME () { return config.get<string>('import.videos.http.youtube_dl_release.name') }, |
337 | get PYTHON_PATH () { return config.get<string>('import.videos.http.youtube_dl_release.python_path') } | ||
314 | }, | 338 | }, |
315 | 339 | ||
316 | get FORCE_IPV4 () { return config.get<boolean>('import.videos.http.force_ipv4') } | 340 | get FORCE_IPV4 () { return config.get<boolean>('import.videos.http.force_ipv4') } |
@@ -497,7 +521,7 @@ export function reloadConfig () { | |||
497 | delete require.cache[fileName] | 521 | delete require.cache[fileName] |
498 | } | 522 | } |
499 | 523 | ||
500 | decache('config') | 524 | decacheModule('config') |
501 | } | 525 | } |
502 | 526 | ||
503 | purge() | 527 | purge() |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index b8633e83e..c899812a6 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -2,7 +2,7 @@ import { CronRepeatOptions, EveryRepeatOptions } from 'bull' | |||
2 | import { randomBytes } from 'crypto' | 2 | import { randomBytes } from 'crypto' |
3 | import { invert } from 'lodash' | 3 | import { invert } from 'lodash' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { randomInt } from '../../shared/core-utils/common/miscs' | 5 | import { randomInt, root } from '@shared/core-utils' |
6 | import { | 6 | import { |
7 | AbuseState, | 7 | AbuseState, |
8 | JobType, | 8 | JobType, |
@@ -19,12 +19,12 @@ import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | |||
19 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' | 19 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' |
20 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' | 20 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' |
21 | // Do not use barrels, remain constants as independent as possible | 21 | // Do not use barrels, remain constants as independent as possible |
22 | import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' | 22 | import { isTestInstance, parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
23 | import { CONFIG, registerConfigChangedHandler } from './config' | 23 | import { CONFIG, registerConfigChangedHandler } from './config' |
24 | 24 | ||
25 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
26 | 26 | ||
27 | const LAST_MIGRATION_VERSION = 670 | 27 | const LAST_MIGRATION_VERSION = 675 |
28 | 28 | ||
29 | // --------------------------------------------------------------------------- | 29 | // --------------------------------------------------------------------------- |
30 | 30 | ||
@@ -200,8 +200,14 @@ const JOB_PRIORITY = { | |||
200 | } | 200 | } |
201 | 201 | ||
202 | const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job | 202 | const BROADCAST_CONCURRENCY = 30 // How many requests in parallel we do in activitypub-http-broadcast job |
203 | const AP_CLEANER_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-cleaner job | ||
204 | const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) | 203 | const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) |
204 | |||
205 | const AP_CLEANER = { | ||
206 | CONCURRENCY: 10, // How many requests in parallel we do in activitypub-cleaner job | ||
207 | UNAVAILABLE_TRESHOLD: 3, // How many attemps we do before removing an unavailable remote resource | ||
208 | PERIOD: parseDurationToMs('1 week') // /!\ Has to be sync with REPEAT_JOBS | ||
209 | } | ||
210 | |||
205 | const REQUEST_TIMEOUTS = { | 211 | const REQUEST_TIMEOUTS = { |
206 | DEFAULT: 7000, // 7 seconds | 212 | DEFAULT: 7000, // 7 seconds |
207 | FILE: 30000, // 30 seconds | 213 | FILE: 30000, // 30 seconds |
@@ -223,7 +229,7 @@ const SCHEDULER_INTERVALS_MS = { | |||
223 | REMOVE_OLD_VIEWS: 60000 * 60 * 24, // 1 day | 229 | REMOVE_OLD_VIEWS: 60000 * 60 * 24, // 1 day |
224 | REMOVE_OLD_HISTORY: 60000 * 60 * 24, // 1 day | 230 | REMOVE_OLD_HISTORY: 60000 * 60 * 24, // 1 day |
225 | UPDATE_INBOX_STATS: 1000 * 60, // 1 minute | 231 | UPDATE_INBOX_STATS: 1000 * 60, // 1 minute |
226 | REMOVE_DANGLING_RESUMABLE_UPLOADS: 60000 * 60 * 16 // 16 hours | 232 | REMOVE_DANGLING_RESUMABLE_UPLOADS: 60000 * 60 // 1 hour |
227 | } | 233 | } |
228 | 234 | ||
229 | // --------------------------------------------------------------------------- | 235 | // --------------------------------------------------------------------------- |
@@ -427,7 +433,8 @@ const VIDEO_STATES: { [ id in VideoState ]: string } = { | |||
427 | [VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream', | 433 | [VideoState.WAITING_FOR_LIVE]: 'Waiting for livestream', |
428 | [VideoState.LIVE_ENDED]: 'Livestream ended', | 434 | [VideoState.LIVE_ENDED]: 'Livestream ended', |
429 | [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage', | 435 | [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'To move to an external storage', |
430 | [VideoState.TRANSCODING_FAILED]: 'Transcoding failed' | 436 | [VideoState.TRANSCODING_FAILED]: 'Transcoding failed', |
437 | [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED]: 'External storage move failed' | ||
431 | } | 438 | } |
432 | 439 | ||
433 | const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = { | 440 | const VIDEO_IMPORT_STATES: { [ id in VideoImportState ]: string } = { |
@@ -795,8 +802,11 @@ if (isTestInstance() === true) { | |||
795 | SCHEDULER_INTERVALS_MS.AUTO_FOLLOW_INDEX_INSTANCES = 5000 | 802 | SCHEDULER_INTERVALS_MS.AUTO_FOLLOW_INDEX_INSTANCES = 5000 |
796 | SCHEDULER_INTERVALS_MS.UPDATE_INBOX_STATS = 5000 | 803 | SCHEDULER_INTERVALS_MS.UPDATE_INBOX_STATS = 5000 |
797 | SCHEDULER_INTERVALS_MS.CHECK_PEERTUBE_VERSION = 2000 | 804 | SCHEDULER_INTERVALS_MS.CHECK_PEERTUBE_VERSION = 2000 |
805 | |||
798 | REPEAT_JOBS['videos-views-stats'] = { every: 5000 } | 806 | REPEAT_JOBS['videos-views-stats'] = { every: 5000 } |
807 | |||
799 | REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 } | 808 | REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 } |
809 | AP_CLEANER.PERIOD = 5000 | ||
800 | 810 | ||
801 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 | 811 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
802 | 812 | ||
@@ -857,7 +867,7 @@ export { | |||
857 | REDUNDANCY, | 867 | REDUNDANCY, |
858 | JOB_CONCURRENCY, | 868 | JOB_CONCURRENCY, |
859 | JOB_ATTEMPTS, | 869 | JOB_ATTEMPTS, |
860 | AP_CLEANER_CONCURRENCY, | 870 | AP_CLEANER, |
861 | LAST_MIGRATION_VERSION, | 871 | LAST_MIGRATION_VERSION, |
862 | OAUTH_LIFETIME, | 872 | OAUTH_LIFETIME, |
863 | CUSTOM_HTML_TAG_COMMENTS, | 873 | CUSTOM_HTML_TAG_COMMENTS, |
@@ -1075,7 +1085,9 @@ function buildLanguages () { | |||
1075 | epo: true, // Esperanto | 1085 | epo: true, // Esperanto |
1076 | tlh: true, // Klingon | 1086 | tlh: true, // Klingon |
1077 | jbo: true, // Lojban | 1087 | jbo: true, // Lojban |
1078 | avk: true // Kotava | 1088 | avk: true, // Kotava |
1089 | |||
1090 | zxx: true // No linguistic content (ISO-639-2) | ||
1079 | } | 1091 | } |
1080 | 1092 | ||
1081 | // Only add ISO639-1 languages and some sign languages (ISO639-3) | 1093 | // Only add ISO639-1 languages and some sign languages (ISO639-3) |
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 75daeb5d8..7e321fb76 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { ensureDir, remove } from 'fs-extra' | 1 | import { ensureDir, remove } from 'fs-extra' |
2 | import passwordGenerator from 'password-generator' | 2 | import passwordGenerator from 'password-generator' |
3 | import { UserRole } from '../../shared' | 3 | import { UserRole } from '@shared/models' |
4 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
5 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' | 5 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' |
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
@@ -144,6 +144,7 @@ async function createOAuthAdminIfNotExist () { | |||
144 | role, | 144 | role, |
145 | verified: true, | 145 | verified: true, |
146 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | 146 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, |
147 | p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED, | ||
147 | videoQuota: -1, | 148 | videoQuota: -1, |
148 | videoQuotaDaily: -1 | 149 | videoQuotaDaily: -1 |
149 | } | 150 | } |
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts index 0e6952350..ef3e15968 100644 --- a/server/initializers/migrations/0080-video-channels.ts +++ b/server/initializers/migrations/0080-video-channels.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { buildUUID } from '@server/helpers/uuid' | 1 | import { buildUUID } from '@shared/extra-utils' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | 3 | ||
4 | async function up (utils: { | 4 | async function up (utils: { |
diff --git a/server/initializers/migrations/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.ts index 8dd631dff..4bf3100e4 100644 --- a/server/initializers/migrations/0345-video-playlists.ts +++ b/server/initializers/migrations/0345-video-playlists.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { buildUUID } from '@server/helpers/uuid' | 2 | import { buildUUID } from '@shared/extra-utils' |
3 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' | 3 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' |
4 | import { WEBSERVER } from '../constants' | 4 | import { WEBSERVER } from '../constants' |
5 | 5 | ||
diff --git a/server/initializers/migrations/0560-user-feed-token.ts b/server/initializers/migrations/0560-user-feed-token.ts index 042301352..4c85b04f7 100644 --- a/server/initializers/migrations/0560-user-feed-token.ts +++ b/server/initializers/migrations/0560-user-feed-token.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { buildUUID } from '@server/helpers/uuid' | 2 | import { buildUUID } from '@shared/extra-utils' |
3 | 3 | ||
4 | async function up (utils: { | 4 | async function up (utils: { |
5 | transaction: Sequelize.Transaction | 5 | transaction: Sequelize.Transaction |
diff --git a/server/initializers/migrations/0675-p2p-enabled.ts b/server/initializers/migrations/0675-p2p-enabled.ts new file mode 100644 index 000000000..b4f53381e --- /dev/null +++ b/server/initializers/migrations/0675-p2p-enabled.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | await utils.queryInterface.renameColumn('user', 'webTorrentEnabled', 'p2pEnabled') | ||
10 | |||
11 | await utils.sequelize.query('ALTER TABLE "user" ALTER COLUMN "p2pEnabled" DROP DEFAULT') | ||
12 | } | ||
13 | |||
14 | function down (options) { | ||
15 | throw new Error('Not implemented.') | ||
16 | } | ||
17 | |||
18 | export { | ||
19 | up, | ||
20 | down | ||
21 | } | ||
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts index 7d7c9f8cb..7ac20127e 100644 --- a/server/initializers/migrator.ts +++ b/server/initializers/migrator.ts | |||
@@ -65,7 +65,7 @@ async function getMigrationScripts () { | |||
65 | }[] = [] | 65 | }[] = [] |
66 | 66 | ||
67 | files | 67 | files |
68 | .filter(file => file.endsWith('.js.map') === false) | 68 | .filter(file => file.endsWith('.js')) |
69 | .forEach(file => { | 69 | .forEach(file => { |
70 | // Filename is something like 'version-blabla.js' | 70 | // Filename is something like 'version-blabla.js' |
71 | const version = file.split('-')[0] | 71 | const version = file.split('-')[0] |