X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.js;h=33d399786da00edd0f787ee8cba3b7819ed09ba9;hb=3758da9489b636997a3a4fad7fc1a6081737bbe0;hp=4a0de72bbfbc1a09de011b247796f74d886fb165;hpb=c1a7ab7f04fdb1601cf1e41c4e372dbd3c81f3de;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.js b/server.js index 4a0de72bb..33d399786 100644 --- a/server.js +++ b/server.js @@ -20,7 +20,7 @@ const constants = require('./server/initializers/constants') const logger = require('./server/helpers/logger') // Initialize database and models const db = require('./server/initializers/database') -db.init() +db.init(onDatabaseInitDone) // ----------- Checker ----------- const checker = require('./server/initializers/checker') @@ -119,25 +119,27 @@ app.use(function (err, req, res, next) { // ----------- Run ----------- -const port = constants.CONFIG.LISTEN.PORT -installer.installApplication(function (err) { - if (err) throw err - - // Run the migration scripts if needed +function onDatabaseInitDone () { + const port = constants.CONFIG.LISTEN.PORT + // Run the migration scripts if needed migrator.migrate(function (err) { if (err) throw err - // ----------- Make the server listening ----------- - server.listen(port, function () { - // Activate the communication with friends - friends.activate() + installer.installApplication(function (err) { + if (err) throw err + + // ----------- Make the server listening ----------- + server.listen(port, function () { + // Activate the communication with friends + friends.activate() - logger.info('Server listening on port %d', port) - logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL) + logger.info('Server listening on port %d', port) + logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL) - app.emit('ready') + app.emit('ready') + }) }) }) -}) +} module.exports = app