-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
executable file
·43 lines (33 loc) · 1003 Bytes
/
app.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
require('dnscache')({
enable: true,
ttl: 600,
cachesize: 100,
});
const stringify = require('simple-stringify');
require('./helpers/local-require');
const config = localRequire('config');
const utils = localRequire('helpers/utils');
localRequire('helpers/logger');
localRequire('helpers/bluebird');
localRequire('helpers/joi');
localRequire('models');
localRequire('helpers/server')(config.port);
localRequire('tasks');
function gracefulExit() {
console.info('the application will be restart');
utils.checkToExit(3);
}
process.on('unhandledRejection', (err) => {
console.error(`unhandledRejection:${err.message}, stack:${err.stack}`);
gracefulExit();
});
process.on('uncaughtException', (err) => {
console.error(`uncaughtException:${err.message}, stack:${err.stack}`);
gracefulExit();
});
if (config.env !== 'development') {
process.on('SIGTERM', gracefulExit);
process.on('SIGQUIT', gracefulExit);
}
// set stringify mask
stringify.isSecret = key => key === 'password';