diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-15 22:22:03 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-20 09:57:40 +0200 |
commit | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch) | |
tree | 4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/initializers/checker.js | |
parent | d5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff) | |
download | PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip |
First typescript iteration
Diffstat (limited to 'server/initializers/checker.js')
-rw-r--r-- | server/initializers/checker.js | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/server/initializers/checker.js b/server/initializers/checker.js deleted file mode 100644 index aa8dea4bf..000000000 --- a/server/initializers/checker.js +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const config = require('config') | ||
4 | |||
5 | const constants = require('./constants') | ||
6 | const db = require('./database') | ||
7 | |||
8 | const checker = { | ||
9 | checkConfig, | ||
10 | checkFFmpeg, | ||
11 | checkMissedConfig, | ||
12 | clientsExist, | ||
13 | usersExist | ||
14 | } | ||
15 | |||
16 | // Some checks on configuration files | ||
17 | function checkConfig () { | ||
18 | if (config.has('webserver.host')) { | ||
19 | let errorMessage = '`host` config key was renamed to `hostname` but it seems you still have a `host` key in your configuration files!' | ||
20 | errorMessage += ' Please ensure to rename your `host` configuration to `hostname`.' | ||
21 | |||
22 | return errorMessage | ||
23 | } | ||
24 | |||
25 | return null | ||
26 | } | ||
27 | |||
28 | // Check the config files | ||
29 | function checkMissedConfig () { | ||
30 | const required = [ 'listen.port', | ||
31 | 'webserver.https', 'webserver.hostname', 'webserver.port', | ||
32 | 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', | ||
33 | 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', | ||
34 | 'admin.email', 'signup.enabled', 'transcoding.enabled', 'transcoding.threads' | ||
35 | ] | ||
36 | const miss = [] | ||
37 | |||
38 | for (const key of required) { | ||
39 | if (!config.has(key)) { | ||
40 | miss.push(key) | ||
41 | } | ||
42 | } | ||
43 | |||
44 | return miss | ||
45 | } | ||
46 | |||
47 | // Check the available codecs | ||
48 | function checkFFmpeg (callback) { | ||
49 | const Ffmpeg = require('fluent-ffmpeg') | ||
50 | |||
51 | Ffmpeg.getAvailableCodecs(function (err, codecs) { | ||
52 | if (err) return callback(err) | ||
53 | if (constants.CONFIG.TRANSCODING.ENABLED === false) return callback(null) | ||
54 | |||
55 | const canEncode = [ 'libx264' ] | ||
56 | canEncode.forEach(function (codec) { | ||
57 | if (codecs[codec] === undefined) { | ||
58 | return callback(new Error('Unknown codec ' + codec + ' in FFmpeg.')) | ||
59 | } | ||
60 | |||
61 | if (codecs[codec].canEncode !== true) { | ||
62 | return callback(new Error('Unavailable encode codec ' + codec + ' in FFmpeg')) | ||
63 | } | ||
64 | }) | ||
65 | |||
66 | return callback(null) | ||
67 | }) | ||
68 | } | ||
69 | |||
70 | function clientsExist (callback) { | ||
71 | db.OAuthClient.countTotal(function (err, totalClients) { | ||
72 | if (err) return callback(err) | ||
73 | |||
74 | return callback(null, totalClients !== 0) | ||
75 | }) | ||
76 | } | ||
77 | |||
78 | function usersExist (callback) { | ||
79 | db.User.countTotal(function (err, totalUsers) { | ||
80 | if (err) return callback(err) | ||
81 | |||
82 | return callback(null, totalUsers !== 0) | ||
83 | }) | ||
84 | } | ||
85 | |||
86 | // --------------------------------------------------------------------------- | ||
87 | |||
88 | module.exports = checker | ||