From 1cd51ef944d8ec0d81985c2b3d650c68712a40d4 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 7 Apr 2015 15:50:13 -0300 Subject: [PATCH] handle SIGINT --- index.js | 4 ++++ lib/node.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/index.js b/index.js index 9b3e729b..8ffbaab9 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,10 @@ if (require.main === module) { console.log('Error: ', err); } }); + process.on('SIGINT', function() { + node.stop(); + process.exit(); + }); var reporterName = config.get('Reporter'); var reporter = reporters[reporterName]; diff --git a/lib/node.js b/lib/node.js index 49a6a1a3..3fc762eb 100644 --- a/lib/node.js +++ b/lib/node.js @@ -86,6 +86,11 @@ BitcoreNode.prototype.start = function() { this.networkMonitor.start(); }; +BitcoreNode.prototype.stop = function() { + this.networkMonitor.stop(); +}; + + BitcoreNode.prototype.sync = function() { var genesis = bitcore.Block.fromBuffer(genesisBlocks[bitcore.Networks.defaultNetwork.name]); var self = this;