ethstats-client/app.js

29 lines
629 B
JavaScript
Raw Normal View History

2015-02-12 13:26:47 +01:00
var nodeModel = require('./lib/node');
2015-02-11 23:54:33 +01:00
2015-02-16 17:44:26 +01:00
var node = new nodeModel();
2015-02-12 13:26:47 +01:00
var gracefulShutdown = function() {
console.log("Received kill signal, shutting down gracefully.");
node.stop();
console.log("Closed node watcher");
setTimeout(function(){
console.log("Closed out remaining connections.");
2015-02-18 05:39:33 +01:00
process.exit(0)
2015-02-12 13:26:47 +01:00
}, 2*1000);
2015-02-11 23:21:10 +01:00
}
2015-02-12 13:26:47 +01:00
// listen for TERM signal .e.g. kill
process.on('SIGTERM', gracefulShutdown);
// listen for INT signal e.g. Ctrl-C
process.on('SIGINT', gracefulShutdown);
2015-02-11 23:21:10 +01:00
2015-02-18 05:39:33 +01:00
process.on('message', function(msg) {
if (msg == 'shutdown')
gracefulShutdown();
});
2015-02-11 23:21:10 +01:00
2015-02-12 23:30:12 +01:00
module.exports = node;