Switched to using a flag instead of using a replacement.

This commit is contained in:
Chris Kleeschulte 2015-09-14 13:15:55 -04:00
parent 51355c51f1
commit 7b50f5ff3d
2 changed files with 8 additions and 9 deletions

View File

@ -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);
}
}
}

View File

@ -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() {