forked from cryptol0g1c/eth-net-intelligence-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (23 loc) · 746 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
'use strict';
var nodeModel = require('./lib/node');
var node = new nodeModel();
var gracefulShutdown = function() {
console.log('');
console.error("xxx", "sys", "Received kill signal, shutting down gracefully.");
node.stop();
console.info("xxx", "sys", "Closed node watcher");
setTimeout(function(){
console.info("xxx", "sys", "Closed out remaining connections.");
process.exit(0);
}, 1000);
}
// listen for TERM signal .e.g. kill
process.on('SIGTERM', gracefulShutdown);
// listen for INT signal e.g. Ctrl-C
process.on('SIGINT', gracefulShutdown);
// listen for shutdown signal from pm2
process.on('message', function(msg) {
if (msg == 'shutdown')
gracefulShutdown();
});
module.exports = node;