diff options
Diffstat (limited to 'server/initializers/checker.ts')
-rw-r--r-- | server/initializers/checker.ts | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts index 52a1aeb50..608123607 100644 --- a/server/initializers/checker.ts +++ b/server/initializers/checker.ts | |||
@@ -43,7 +43,7 @@ function checkMissedConfig () { | |||
43 | const required = [ 'listen.port', 'listen.hostname', | 43 | const required = [ 'listen.port', 'listen.hostname', |
44 | 'webserver.https', 'webserver.hostname', 'webserver.port', | 44 | 'webserver.https', 'webserver.hostname', 'webserver.port', |
45 | 'trust_proxy', | 45 | 'trust_proxy', |
46 | 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', | 46 | 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', |
47 | 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', | 47 | 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', |
48 | 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', | 48 | 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', |
49 | 'log.level', | 49 | 'log.level', |
@@ -51,6 +51,7 @@ function checkMissedConfig () { | |||
51 | 'cache.previews.size', 'admin.email', | 51 | 'cache.previews.size', 'admin.email', |
52 | 'signup.enabled', 'signup.limit', 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist', | 52 | 'signup.enabled', 'signup.limit', 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist', |
53 | 'transcoding.enabled', 'transcoding.threads', | 53 | 'transcoding.enabled', 'transcoding.threads', |
54 | 'import.videos.http.enabled', | ||
54 | 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', | 55 | 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', |
55 | 'instance.default_nsfw_policy', 'instance.robots', | 56 | 'instance.default_nsfw_policy', 'instance.robots', |
56 | 'services.twitter.username', 'services.twitter.whitelisted' | 57 | 'services.twitter.username', 'services.twitter.whitelisted' |
@@ -84,11 +85,11 @@ function checkMissedConfig () { | |||
84 | async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { | 85 | async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { |
85 | const Ffmpeg = require('fluent-ffmpeg') | 86 | const Ffmpeg = require('fluent-ffmpeg') |
86 | const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) | 87 | const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) |
87 | |||
88 | const codecs = await getAvailableCodecsPromise() | 88 | const codecs = await getAvailableCodecsPromise() |
89 | const canEncode = [ 'libx264' ] | ||
90 | |||
89 | if (CONFIG.TRANSCODING.ENABLED === false) return undefined | 91 | if (CONFIG.TRANSCODING.ENABLED === false) return undefined |
90 | 92 | ||
91 | const canEncode = [ 'libx264' ] | ||
92 | for (const codec of canEncode) { | 93 | for (const codec of canEncode) { |
93 | if (codecs[codec] === undefined) { | 94 | if (codecs[codec] === undefined) { |
94 | throw new Error('Unknown codec ' + codec + ' in FFmpeg.') | 95 | throw new Error('Unknown codec ' + codec + ' in FFmpeg.') |
@@ -98,6 +99,29 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { | |||
98 | throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') | 99 | throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') |
99 | } | 100 | } |
100 | } | 101 | } |
102 | |||
103 | checkFFmpegEncoders() | ||
104 | } | ||
105 | |||
106 | // Optional encoders, if present, can be used to improve transcoding | ||
107 | // Here we ask ffmpeg if it detects their presence on the system, so that we can later use them | ||
108 | let supportedOptionalEncoders: Map<string, boolean> | ||
109 | async function checkFFmpegEncoders (): Promise<Map<string, boolean>> { | ||
110 | if (supportedOptionalEncoders !== undefined) { | ||
111 | return supportedOptionalEncoders | ||
112 | } | ||
113 | |||
114 | const Ffmpeg = require('fluent-ffmpeg') | ||
115 | const getAvailableEncodersPromise = promisify0(Ffmpeg.getAvailableEncoders) | ||
116 | const encoders = await getAvailableEncodersPromise() | ||
117 | const optionalEncoders = [ 'libfdk_aac' ] | ||
118 | supportedOptionalEncoders = new Map<string, boolean>() | ||
119 | |||
120 | for (const encoder of optionalEncoders) { | ||
121 | supportedOptionalEncoders.set(encoder, | ||
122 | encoders[encoder] !== undefined | ||
123 | ) | ||
124 | } | ||
101 | } | 125 | } |
102 | 126 | ||
103 | // We get db by param to not import it in this file (import orders) | 127 | // We get db by param to not import it in this file (import orders) |
@@ -126,6 +150,7 @@ async function applicationExist () { | |||
126 | export { | 150 | export { |
127 | checkConfig, | 151 | checkConfig, |
128 | checkFFmpeg, | 152 | checkFFmpeg, |
153 | checkFFmpegEncoders, | ||
129 | checkMissedConfig, | 154 | checkMissedConfig, |
130 | clientsExist, | 155 | clientsExist, |
131 | usersExist, | 156 | usersExist, |