diff options
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 |