aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-01 19:46:07 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-01 19:46:07 +0100
commitb65c27aaf7f6ea193d8f3bbf6fe4220f16219e06 (patch)
treee25975ee13ad96714e8cb1f8027c95b3a22ad113
parent763381deafebc660657ff175210a9585962ed9c4 (diff)
downloadPeerTube-b65c27aaf7f6ea193d8f3bbf6fe4220f16219e06.tar.gz
PeerTube-b65c27aaf7f6ea193d8f3bbf6fe4220f16219e06.tar.zst
PeerTube-b65c27aaf7f6ea193d8f3bbf6fe4220f16219e06.zip
Server: check the host key is not present in configurations
The parameter was renamed to hostname
-rw-r--r--server.js11
-rw-r--r--server/initializers/checker.js15
2 files changed, 22 insertions, 4 deletions
diff --git a/server.js b/server.js
index 317b6ed77..18d9a087c 100644
--- a/server.js
+++ b/server.js
@@ -26,9 +26,14 @@ database.connect()
26// ----------- Checker ----------- 26// ----------- Checker -----------
27const checker = require('./server/initializers/checker') 27const checker = require('./server/initializers/checker')
28 28
29const miss = checker.checkConfig() 29const missed = checker.checkMissedConfig()
30if (miss.length !== 0) { 30if (missed.length !== 0) {
31 throw new Error('Miss some configurations keys : ' + miss) 31 throw new Error('Miss some configurations keys : ' + missed)
32}
33
34const errorMessage = checker.checkConfig()
35if (errorMessage !== null) {
36 throw new Error(errorMessage)
32} 37}
33 38
34// ----------- PeerTube modules ----------- 39// ----------- PeerTube modules -----------
diff --git a/server/initializers/checker.js b/server/initializers/checker.js
index 4ecabac77..dad8525fa 100644
--- a/server/initializers/checker.js
+++ b/server/initializers/checker.js
@@ -8,12 +8,25 @@ const User = mongoose.model('User')
8 8
9const checker = { 9const checker = {
10 checkConfig, 10 checkConfig,
11 checkMissedConfig,
11 clientsExist, 12 clientsExist,
12 usersExist 13 usersExist
13} 14}
14 15
15// Check the config files 16// Some checks on configuration files
16function checkConfig () { 17function 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
29function checkMissedConfig () {
17 const required = [ 'listen.port', 30 const required = [ 'listen.port',
18 'webserver.https', 'webserver.hostname', 'webserver.port', 31 'webserver.https', 'webserver.hostname', 'webserver.port',
19 'database.hostname', 'database.port', 'database.suffix', 32 'database.hostname', 'database.port', 'database.suffix',