-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
61 lines (53 loc) · 1.31 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require('@babel/register')({
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
}
}],
"@babel/preset-react"
],
"plugins": [
[
"module-resolver",
{
"root": [
"./"
],
"alias": {}
}
],
"transform-promise-to-bluebird",
"@babel/plugin-proposal-class-properties"
]
});
require.extensions['.css'] = () => {
return;
};
var express = require('express');
var config = require('./config/config').default;
function registerGracefulShutdown(signal, server, id) {
process.on(signal, function() {
console.log(`Server(${id}) received signal ${signal}, attempt exit`);
server.close(function() {
console.log(`Server(${id}) finished closing, exiting`);
process.exit(0);
});
});
}
function startThisProcess(app, id) {
return new Promise(function(resolve, reject) {
id = id || 'main';
const server = app.listen(config.port, function() {
console.log(`Server(${id}) listening on port ${config.port}`);
});
registerGracefulShutdown('SIGTERM', server, id);
registerGracefulShutdown('SIGINT', server, id);
resolve();
});
}
var realapp = express();
var app = require('./app/app.js').default;
realapp.use("/portal",app);
realapp.use("/",app);
startThisProcess(realapp);