const logger = require('./server/helpers/logger')
// Initialize database and models
const db = require('./server/initializers/database')
-db.init()
+db.init(onDatabaseInitDone)
// ----------- Checker -----------
const checker = require('./server/initializers/checker')
// ----------- Run -----------
-const port = constants.CONFIG.LISTEN.PORT
-installer.installApplication(function (err) {
- if (err) throw err
-
- // Run the migration scripts if needed
+function onDatabaseInitDone () {
+ const port = constants.CONFIG.LISTEN.PORT
+ // Run the migration scripts if needed
migrator.migrate(function (err) {
if (err) throw err
- // ----------- Make the server listening -----------
- server.listen(port, function () {
- // Activate the communication with friends
- friends.activate()
+ installer.installApplication(function (err) {
+ if (err) throw err
+
+ // ----------- Make the server listening -----------
+ server.listen(port, function () {
+ // Activate the communication with friends
+ friends.activate()
- logger.info('Server listening on port %d', port)
- logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL)
+ logger.info('Server listening on port %d', port)
+ logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL)
- app.emit('ready')
+ app.emit('ready')
+ })
})
})
-})
+}
module.exports = app