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;