aboutsummaryrefslogtreecommitdiffhomepage
path: root/initializers/checker.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-01-30 17:05:22 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-01-30 17:05:22 +0100
commitcda021079ff455cc0fd0eb95a5395fa808ab63d1 (patch)
tree056716de7460462b74b861051a5e9da6e2633fce /initializers/checker.js
parent86435b9baedfe300a28ea4545511c1b50d4119f6 (diff)
downloadPeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.gz
PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.zst
PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.zip
New directory organization
Diffstat (limited to 'initializers/checker.js')
-rw-r--r--initializers/checker.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/initializers/checker.js b/initializers/checker.js
new file mode 100644
index 000000000..7a3a53616
--- /dev/null
+++ b/initializers/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.createDirectoriesIfNotExist = 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})()