From 7b50f5ff3d1448a60a46bd590ac40aadf8b41367 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Mon, 14 Sep 2015 13:15:55 -0400 Subject: [PATCH] Switched to using a flag instead of using a replacement. --- lib/scaffold/start.js | 7 +++++-- test/scaffold/start.unit.js | 10 +++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/scaffold/start.js b/lib/scaffold/start.js index 512733ad..0d24228e 100644 --- a/lib/scaffold/start.js +++ b/lib/scaffold/start.js @@ -9,6 +9,7 @@ var $ = bitcore.util.preconditions; var log = index.log; var child_process = require('child_process'); var fs = require('fs'); +var shuttingDown = false; log.debug = function() {}; @@ -168,8 +169,10 @@ function exitHandler(options, _process, node, err) { }); } if (options.sigint) { - _process.on('SIGINT', function(){}); - start.cleanShutdown(_process, node); + if (!shuttingDown) { + shuttingDown = true; + start.cleanShutdown(_process, node); + } } } diff --git a/test/scaffold/start.unit.js b/test/scaffold/start.unit.js index b3aafc6d..c955cbf9 100644 --- a/test/scaffold/start.unit.js +++ b/test/scaffold/start.unit.js @@ -355,14 +355,10 @@ describe('#start', function() { it('should replace the listener for SIGINT after the first SIGINT is handled', function() { var options = { sigint: true }; var node = {}; - var replacementFunc = sinon.stub(); - replacementFunc.withArgs('SIGINT', function(){}); - var testProcess = { - on: replacementFunc - } - exitHandler(options, testProcess, node); + exitHandler(options, process, node); + cleanShutdown.callCount.should.equal(1); + exitHandler(options, process, node); cleanShutdown.callCount.should.equal(1); - replacementFunc.callCount.should.equal(1); }); it('should log all errors and stops the services nonetheless', function() {