aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /server.ts
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-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.ts20
1 files changed, 7 insertions, 13 deletions
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'
29import { API_VERSION, CONFIG } from './server/initializers/constants' 29import { API_VERSION, CONFIG } from './server/initializers/constants'
30// Initialize database and models 30// Initialize database and models
31import { database as db } from './server/initializers/database' 31import { database as db } from './server/initializers/database'
32db.init(false, onDatabaseInitDone) 32db.init(false).then(() => onDatabaseInitDone())
33 33
34// ----------- Checker ----------- 34// ----------- Checker -----------
35import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker' 35import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker'
@@ -38,11 +38,7 @@ const missed = checkMissedConfig()
38if (missed.length !== 0) { 38if (missed.length !== 0) {
39 throw new Error('Miss some configurations keys : ' + missed) 39 throw new Error('Miss some configurations keys : ' + missed)
40} 40}
41checkFFmpeg(function (err) { 41checkFFmpeg()
42 if (err) {
43 throw err
44 }
45})
46 42
47const errorMessage = checkConfig() 43const errorMessage = checkConfig()
48if (errorMessage !== null) { 44if (errorMessage !== null) {
@@ -138,12 +134,11 @@ app.use(function (err, req, res, next) {
138function onDatabaseInitDone () { 134function 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}