aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-18 11:56:28 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-18 12:13:33 +0100
commit5804c0db337ecf492fc61b98a3de7b730a0d8ce3 (patch)
tree83c0e8d8f10ec0f9ca269624feaba48970a7a0e3 /server.js
parentc1a7ab7f04fdb1601cf1e41c4e372dbd3c81f3de (diff)
downloadPeerTube-5804c0db337ecf492fc61b98a3de7b730a0d8ce3.tar.gz
PeerTube-5804c0db337ecf492fc61b98a3de7b730a0d8ce3.tar.zst
PeerTube-5804c0db337ecf492fc61b98a3de7b730a0d8ce3.zip
Server: fix migration scripts
Diffstat (limited to 'server.js')
-rw-r--r--server.js30
1 files changed, 16 insertions, 14 deletions
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')
20const logger = require('./server/helpers/logger') 20const logger = require('./server/helpers/logger')
21// Initialize database and models 21// Initialize database and models
22const db = require('./server/initializers/database') 22const db = require('./server/initializers/database')
23db.init() 23db.init(onDatabaseInitDone)
24 24
25// ----------- Checker ----------- 25// ----------- Checker -----------
26const checker = require('./server/initializers/checker') 26const checker = require('./server/initializers/checker')
@@ -119,25 +119,27 @@ app.use(function (err, req, res, next) {
119 119
120// ----------- Run ----------- 120// ----------- Run -----------
121 121
122const port = constants.CONFIG.LISTEN.PORT 122function onDatabaseInitDone () {
123installer.installApplication(function (err) { 123 const port = constants.CONFIG.LISTEN.PORT
124 if (err) throw err 124 // Run the migration scripts if needed
125
126 // Run the migration scripts if needed
127 migrator.migrate(function (err) { 125 migrator.migrate(function (err) {
128 if (err) throw err 126 if (err) throw err
129 127
130 // ----------- Make the server listening ----------- 128 installer.installApplication(function (err) {
131 server.listen(port, function () { 129 if (err) throw err
132 // Activate the communication with friends 130
133 friends.activate() 131 // ----------- Make the server listening -----------
132 server.listen(port, function () {
133 // Activate the communication with friends
134 friends.activate()
134 135
135 logger.info('Server listening on port %d', port) 136 logger.info('Server listening on port %d', port)
136 logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL) 137 logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL)
137 138
138 app.emit('ready') 139 app.emit('ready')
140 })
139 }) 141 })
140 }) 142 })
141}) 143}
142 144
143module.exports = app 145module.exports = app