X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fchecker-after-init.ts;h=09e878eee27df0b42f610d838b23aa9dd5d36587;hb=77239b425a8e00822a53c9907415832a473c3eb6;hp=635a32010b66dab45b1130daabff4e5ff0ada095;hpb=7b51ede977c299a74728171d8c124bcc4cbba6ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 635a32010..09e878eee 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -1,10 +1,10 @@ import config from 'config' -import { uniq } from 'lodash' import { URL } from 'url' import { getFFmpegVersion } from '@server/helpers/ffmpeg' +import { uniqify } from '@shared/core-utils' import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' import { RecentlyAddedStrategy } from '../../shared/models/redundancy' -import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils' +import { isProdInstance, parseSemVersion } from '../helpers/core-utils' import { isArray } from '../helpers/custom-validators/misc' import { logger } from '../helpers/logger' import { ApplicationModel, getServerActor } from '../models/application/application' @@ -34,22 +34,27 @@ async function checkActivityPubUrls () { // Some checks on configuration files or throw if there is an error function checkConfig () { + const configFiles = config.util.getConfigSources().map(s => s.name).join(' -> ') + logger.info('Using following configuration file hierarchy: %s.', configFiles) + // Moved configuration keys if (config.has('services.csp-logger')) { logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.') } + checkSecretsConfig() checkEmailConfig() checkNSFWPolicyConfig() checkLocalRedundancyConfig() checkRemoteRedundancyConfig() checkStorageConfig() checkTranscodingConfig() + checkImportConfig() checkBroadcastMessageConfig() checkSearchConfig() checkLiveConfig() checkObjectStorageConfig() - checkVideoEditorConfig() + checkVideoStudioConfig() } // We get db by param to not import it in this file (import orders) @@ -75,10 +80,14 @@ async function applicationExist () { async function checkFFmpegVersion () { const version = await getFFmpegVersion() - const { major, minor } = parseSemVersion(version) + const { major, minor, patch } = parseSemVersion(version) if (major < 4 || (major === 4 && minor < 1)) { - logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade.', version) + logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade ffmpeg.', version) + } + + if (major === 4 && minor === 4 && patch === 0) { + logger.warn('There is a bug in ffmpeg 4.4.0 with HLS videos. Please upgrade ffmpeg.') } } @@ -95,6 +104,12 @@ export { // --------------------------------------------------------------------------- +function checkSecretsConfig () { + if (!CONFIG.SECRETS.PEERTUBE) { + throw new Error('secrets.peertube is missing in config. Generate one using `openssl rand -hex 32`') + } +} + function checkEmailConfig () { if (!isEmailEnabled()) { if (CONFIG.SIGNUP.ENABLED && CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { @@ -128,12 +143,12 @@ function checkLocalRedundancyConfig () { } // Lifetime should not be < 10 hours - if (!isTestInstance() && r.minLifetime < 1000 * 3600 * 10) { + if (isProdInstance() && r.minLifetime < 1000 * 3600 * 10) { throw new Error('Video redundancy minimum lifetime should be >= 10 hours for strategy ' + r.strategy) } } - const filtered = uniq(redundancyVideos.map(r => r.strategy)) + const filtered = uniqify(redundancyVideos.map(r => r.strategy)) if (filtered.length !== redundancyVideos.length) { throw new Error('Redundancy video entries should have unique strategies') } @@ -193,6 +208,12 @@ function checkTranscodingConfig () { } } +function checkImportConfig () { + if (CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED && !CONFIG.IMPORT.VIDEOS.HTTP) { + throw new Error('You need to enable HTTP import to allow synchronization') + } +} + function checkBroadcastMessageConfig () { if (CONFIG.BROADCAST_MESSAGE.ENABLED) { const currentLevel = CONFIG.BROADCAST_MESSAGE.LEVEL @@ -257,11 +278,19 @@ function checkObjectStorageConfig () { 'Object storage bucket prefixes should be set to different values when the same bucket is used for both types of video.' ) } + + if (!CONFIG.OBJECT_STORAGE.UPLOAD_ACL.PUBLIC) { + throw new Error('object_storage.upload_acl.public must be set') + } + + if (!CONFIG.OBJECT_STORAGE.UPLOAD_ACL.PRIVATE) { + throw new Error('object_storage.upload_acl.private must be set') + } } } -function checkVideoEditorConfig () { - if (CONFIG.VIDEO_EDITOR.ENABLED === true && CONFIG.TRANSCODING.ENABLED === false) { - throw new Error('Video editor cannot be enabled if transcoding is disabled') +function checkVideoStudioConfig () { + if (CONFIG.VIDEO_STUDIO.ENABLED === true && CONFIG.TRANSCODING.ENABLED === false) { + throw new Error('Video studio cannot be enabled if transcoding is disabled') } }