diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-06-09 17:41:40 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-10-29 23:14:54 +0100 |
commit | 8c308c2bf7f658945d80be9d5880361238635f5b (patch) | |
tree | 2130ae60af58e59dab3df07a5d5cdd5174f91ae8 /src/checker.js | |
parent | 8cb4b4e00ee57eb98dfe1455b6d2de36fc561797 (diff) | |
download | PeerTube-8c308c2bf7f658945d80be9d5880361238635f5b.tar.gz PeerTube-8c308c2bf7f658945d80be9d5880361238635f5b.tar.zst PeerTube-8c308c2bf7f658945d80be9d5880361238635f5b.zip |
Spawn
Diffstat (limited to 'src/checker.js')
-rw-r--r-- | src/checker.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/checker.js b/src/checker.js new file mode 100644 index 000000000..fd828ca8c --- /dev/null +++ b/src/checker.js | |||
@@ -0,0 +1,45 @@ | |||
1 | ;(function () { | ||
2 | 'use strict' | ||
3 | |||
4 | var config = require('config') | ||
5 | var mkdirp = require('mkdirp') | ||
6 | |||
7 | var checker = {} | ||
8 | |||
9 | // Check the config files | ||
10 | checker.checkConfig = function () { | ||
11 | var required = [ 'listen.port', | ||
12 | 'webserver.https', 'webserver.host', 'webserver.port', | ||
13 | 'database.host', 'database.port', 'database.suffix', | ||
14 | 'storage.certs', 'storage.uploads', 'storage.logs', | ||
15 | 'network.friends' ] | ||
16 | var miss = [] | ||
17 | |||
18 | for (var key of required) { | ||
19 | if (!config.has(key)) { | ||
20 | miss.push(key) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | return miss | ||
25 | } | ||
26 | |||
27 | // Create directories for the storage if it doesn't exist | ||
28 | checker.createDirectories = function () { | ||
29 | var storages = config.get('storage') | ||
30 | |||
31 | for (var key of Object.keys(storages)) { | ||
32 | var path = storages[key] | ||
33 | try { | ||
34 | mkdirp.sync(__dirname + '/../' + path) | ||
35 | } catch (error) { | ||
36 | // Do not use logger | ||
37 | console.error('Cannot create ' + path + ':' + error) | ||
38 | process.exit(0) | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | |||
43 | // ----------- Export ----------- | ||
44 | module.exports = checker | ||
45 | })() | ||