]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/initializers/checker.js
Server: add webserver url log at startup
[github/Chocobozzz/PeerTube.git] / server / initializers / checker.js
... / ...
CommitLineData
1'use strict'
2
3const config = require('config')
4const mongoose = require('mongoose')
5
6const Client = mongoose.model('OAuthClient')
7const User = mongoose.model('User')
8
9const checker = {
10 checkConfig,
11 clientsExist,
12 usersExist
13}
14
15// Check the config files
16function checkConfig () {
17 const required = [ 'listen.port',
18 'webserver.https', 'webserver.hostname', 'webserver.port',
19 'database.hostname', 'database.port', 'database.suffix',
20 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails'
21 ]
22 const miss = []
23
24 for (const key of required) {
25 if (!config.has(key)) {
26 miss.push(key)
27 }
28 }
29
30 return miss
31}
32
33function clientsExist (callback) {
34 Client.list(function (err, clients) {
35 if (err) return callback(err)
36
37 return callback(null, clients.length !== 0)
38 })
39}
40
41function usersExist (callback) {
42 User.countTotal(function (err, totalUsers) {
43 if (err) return callback(err)
44
45 return callback(null, totalUsers !== 0)
46 })
47}
48
49// ---------------------------------------------------------------------------
50
51module.exports = checker