X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.ts;h=e7fa99c90d49f4965a1b315c3ba0438c156c1f58;hb=ad0997adfb9e1e3b1ff54338d7558cf7b18440ea;hp=60045865d12e3ad6645eea0a4344244028d89571;hpb=1840c2f7c91f5f89602a3683d85b0a9df1454855;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.ts b/server.ts index 60045865d..e7fa99c90 100644 --- a/server.ts +++ b/server.ts @@ -29,7 +29,7 @@ import { logger } from './server/helpers/logger' import { API_VERSION, CONFIG } from './server/initializers/constants' // Initialize database and models import { database as db } from './server/initializers/database' -db.init(false, onDatabaseInitDone) +db.init(false).then(() => onDatabaseInitDone()) // ----------- Checker ----------- import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker' @@ -38,11 +38,7 @@ const missed = checkMissedConfig() if (missed.length !== 0) { throw new Error('Miss some configurations keys : ' + missed) } -checkFFmpeg(function (err) { - if (err) { - throw err - } -}) +checkFFmpeg() const errorMessage = checkConfig() if (errorMessage !== null) { @@ -138,12 +134,11 @@ app.use(function (err, req, res, next) { function onDatabaseInitDone () { const port = CONFIG.LISTEN.PORT // Run the migration scripts if needed - migrate(function (err) { - if (err) throw err - - installApplication(function (err) { - if (err) throw err - + migrate() + .then(() => { + return installApplication() + }) + .then(() => { // ----------- Make the server listening ----------- server.listen(port, function () { // Activate the communication with friends @@ -156,5 +151,4 @@ function onDatabaseInitDone () { logger.info('Webserver: %s', CONFIG.WEBSERVER.URL) }) }) - }) }