2016-06-11 16:27:23 +02:00
|
|
|
#!/usr/bin/env node
|
2014-05-12 20:08:19 +02:00
|
|
|
/*jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2016-06-21 22:59:37 +02:00
|
|
|
(function () {
|
|
|
|
// Use graceful-fs instead of fs also in all libraries to have more robust fs handling.
|
2018-12-17 21:52:19 +01:00
|
|
|
const realFs = require('fs');
|
|
|
|
const gracefulFs = require('graceful-fs');
|
2016-06-21 22:59:37 +02:00
|
|
|
gracefulFs.gracefulify(realFs);
|
|
|
|
})();
|
|
|
|
|
2018-12-17 22:49:54 +01:00
|
|
|
const config = require('./config').config;
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2018-12-17 22:49:54 +01:00
|
|
|
const Logger = require('./logger')
|
|
|
|
Logger.tag('main', 'startup').info('Server starting up...');
|
2016-05-21 17:06:24 +02:00
|
|
|
|
2018-12-17 22:49:54 +01:00
|
|
|
require('./db/database').init()
|
|
|
|
.then(() => {
|
|
|
|
Logger.tag('main').info('Initializing...');
|
2016-05-21 17:06:24 +02:00
|
|
|
|
2018-12-17 22:49:54 +01:00
|
|
|
const app = require('./app');
|
2016-05-24 16:40:57 +02:00
|
|
|
|
2018-12-17 22:49:54 +01:00
|
|
|
require('./jobs/scheduler').init();
|
|
|
|
require('./router').init();
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2018-12-17 22:49:54 +01:00
|
|
|
app.listen(config.server.port, '::');
|
|
|
|
module.exports = app;
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2018-12-17 21:52:19 +01:00
|
|
|
console.error('Could not init database: ', error);
|
|
|
|
process.exit(1);
|
2014-05-12 20:08:19 +02:00
|
|
|
});
|