diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-02-18 11:56:28 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-02-18 12:13:33 +0100 |
commit | 5804c0db337ecf492fc61b98a3de7b730a0d8ce3 (patch) | |
tree | 83c0e8d8f10ec0f9ca269624feaba48970a7a0e3 /server.js | |
parent | c1a7ab7f04fdb1601cf1e41c4e372dbd3c81f3de (diff) | |
download | PeerTube-5804c0db337ecf492fc61b98a3de7b730a0d8ce3.tar.gz PeerTube-5804c0db337ecf492fc61b98a3de7b730a0d8ce3.tar.zst PeerTube-5804c0db337ecf492fc61b98a3de7b730a0d8ce3.zip |
Server: fix migration scripts
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -20,7 +20,7 @@ const constants = require('./server/initializers/constants') | |||
20 | const logger = require('./server/helpers/logger') | 20 | const logger = require('./server/helpers/logger') |
21 | // Initialize database and models | 21 | // Initialize database and models |
22 | const db = require('./server/initializers/database') | 22 | const db = require('./server/initializers/database') |
23 | db.init() | 23 | db.init(onDatabaseInitDone) |
24 | 24 | ||
25 | // ----------- Checker ----------- | 25 | // ----------- Checker ----------- |
26 | const checker = require('./server/initializers/checker') | 26 | const checker = require('./server/initializers/checker') |
@@ -119,25 +119,27 @@ app.use(function (err, req, res, next) { | |||
119 | 119 | ||
120 | // ----------- Run ----------- | 120 | // ----------- Run ----------- |
121 | 121 | ||
122 | const port = constants.CONFIG.LISTEN.PORT | 122 | function onDatabaseInitDone () { |
123 | installer.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 | ||
143 | module.exports = app | 145 | module.exports = app |