-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (29 loc) · 898 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var config = require('config');
var express = require('express');
var app = express();
var log = require('./app/core/log/')(module);
var mongooseUtil = require('./app/core/mongoose/');
var server = function (cb) {
mongooseUtil.init(function () {
var expressUtil = require('./app/core/express/');
var passportUtil = require('./app/core/passport/');
passportUtil.init(app);
expressUtil.init(app);
app.listen(config.server.port, function () {
log.info('App is started at port:', config.server.port);
if (cb) {
cb();
}
});
});
};
if (require.main === module) {
log.info('Server is started in standalone mode');
server();
} else {
log.info('Server is started for testing');
module.exports = server;
}
process.on('uncaughtException', function (err) {
log.error(JSON.parse(JSON.stringify(err, ['stack', 'message', 'inner'], 2)));
});