ethstats-client/app.js

33 lines
746 B
JavaScript
Raw Normal View History

2015-04-29 22:34:52 +02:00
'use strict';
2015-02-11 23:54:33 +01:00
2015-04-04 03:20:12 +02:00
var nodeModel = require('./lib/node');
2015-02-16 17:44:26 +01:00
var node = new nodeModel();
2015-02-12 13:26:47 +01:00
var gracefulShutdown = function() {
2015-05-05 05:59:48 +02:00
console.log('');
console.error("xxx", "sys", "Received kill signal, shutting down gracefully.");
2015-02-12 13:26:47 +01:00
node.stop();
2015-05-05 05:59:48 +02:00
console.info("xxx", "sys", "Closed node watcher");
2015-02-12 13:26:47 +01:00
setTimeout(function(){
2015-05-05 05:59:48 +02:00
console.info("xxx", "sys", "Closed out remaining connections.");
2015-04-28 16:59:36 +02:00
process.exit(0);
2015-06-09 05:33:38 +02:00
}, 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-27 00:24:43 +01:00
// listen for shutdown signal from pm2
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;