diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 13:26:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 14:14:16 +0200 |
commit | 6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch) | |
tree | 3365a96d82bc7f00ae504a568725c8e914150cf8 /server.ts | |
parent | 5fe7e898316e18369c3e1aba307b55077adc7bfb (diff) | |
download | PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip |
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -29,7 +29,7 @@ import { logger } from './server/helpers/logger' | |||
29 | import { API_VERSION, CONFIG } from './server/initializers/constants' | 29 | import { API_VERSION, CONFIG } from './server/initializers/constants' |
30 | // Initialize database and models | 30 | // Initialize database and models |
31 | import { database as db } from './server/initializers/database' | 31 | import { database as db } from './server/initializers/database' |
32 | db.init(false, onDatabaseInitDone) | 32 | db.init(false).then(() => onDatabaseInitDone()) |
33 | 33 | ||
34 | // ----------- Checker ----------- | 34 | // ----------- Checker ----------- |
35 | import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker' | 35 | import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker' |
@@ -38,11 +38,7 @@ const missed = checkMissedConfig() | |||
38 | if (missed.length !== 0) { | 38 | if (missed.length !== 0) { |
39 | throw new Error('Miss some configurations keys : ' + missed) | 39 | throw new Error('Miss some configurations keys : ' + missed) |
40 | } | 40 | } |
41 | checkFFmpeg(function (err) { | 41 | checkFFmpeg() |
42 | if (err) { | ||
43 | throw err | ||
44 | } | ||
45 | }) | ||
46 | 42 | ||
47 | const errorMessage = checkConfig() | 43 | const errorMessage = checkConfig() |
48 | if (errorMessage !== null) { | 44 | if (errorMessage !== null) { |
@@ -138,12 +134,11 @@ app.use(function (err, req, res, next) { | |||
138 | function onDatabaseInitDone () { | 134 | function onDatabaseInitDone () { |
139 | const port = CONFIG.LISTEN.PORT | 135 | const port = CONFIG.LISTEN.PORT |
140 | // Run the migration scripts if needed | 136 | // Run the migration scripts if needed |
141 | migrate(function (err) { | 137 | migrate() |
142 | if (err) throw err | 138 | .then(() => { |
143 | 139 | return installApplication() | |
144 | installApplication(function (err) { | 140 | }) |
145 | if (err) throw err | 141 | .then(() => { |
146 | |||
147 | // ----------- Make the server listening ----------- | 142 | // ----------- Make the server listening ----------- |
148 | server.listen(port, function () { | 143 | server.listen(port, function () { |
149 | // Activate the communication with friends | 144 | // Activate the communication with friends |
@@ -156,5 +151,4 @@ function onDatabaseInitDone () { | |||
156 | logger.info('Webserver: %s', CONFIG.WEBSERVER.URL) | 151 | logger.info('Webserver: %s', CONFIG.WEBSERVER.URL) |
157 | }) | 152 | }) |
158 | }) | 153 | }) |
159 | }) | ||
160 | } | 154 | } |