]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/checker.js
aea013fa9ab169a072f8f048c7cc7e151901ae86
3 const config
= require('config')
4 const mongoose
= require('mongoose')
6 const Client
= mongoose
.model('OAuthClient')
7 const User
= mongoose
.model('User')
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`.'
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',
33 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews'
37 for (const key
of required
) {
38 if (!config
.has(key
)) {
46 function clientsExist (callback
) {
47 Client
.list(function (err
, clients
) {
48 if (err
) return callback(err
)
50 return callback(null, clients
.length
!== 0)
54 function usersExist (callback
) {
55 User
.countTotal(function (err
, totalUsers
) {
56 if (err
) return callback(err
)
58 return callback(null, totalUsers
!== 0)
62 // ---------------------------------------------------------------------------
64 module
.exports
= checker