bitcoind: handle empty input from pid file
This commit is contained in:
parent
2e912af9b4
commit
b0290899ce
@ -643,6 +643,10 @@ Bitcoin.prototype._stopSpawnedBitcoin = function(callback) {
|
||||
return callback(err);
|
||||
}
|
||||
pid = parseInt(pid);
|
||||
if (!Number.isFinite(pid)) {
|
||||
// pid doesn't exist we can continue
|
||||
return callback(null);
|
||||
}
|
||||
try {
|
||||
log.warn('Stopping existing spawned bitcoin process with pid: ' + pid);
|
||||
self._process.kill(pid, 'SIGINT');
|
||||
|
||||
@ -1059,6 +1059,44 @@ describe('Bitcoin Service', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('it will attempt to kill process with NaN', function(done) {
|
||||
var readFile = sandbox.stub();
|
||||
readFile.onCall(0).callsArgWith(2, null, ' ');
|
||||
var TestBitcoinService = proxyquire('../../lib/services/bitcoind', {
|
||||
fs: {
|
||||
readFile: readFile
|
||||
}
|
||||
});
|
||||
var bitcoind = new TestBitcoinService(baseConfig);
|
||||
bitcoind.spawnStopTime = 1;
|
||||
bitcoind._process = {};
|
||||
bitcoind._process.kill = sinon.stub();
|
||||
bitcoind._stopSpawnedBitcoin(function(err) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('it will attempt to kill process without pid', function(done) {
|
||||
var readFile = sandbox.stub();
|
||||
readFile.onCall(0).callsArgWith(2, null, '');
|
||||
var TestBitcoinService = proxyquire('../../lib/services/bitcoind', {
|
||||
fs: {
|
||||
readFile: readFile
|
||||
}
|
||||
});
|
||||
var bitcoind = new TestBitcoinService(baseConfig);
|
||||
bitcoind.spawnStopTime = 1;
|
||||
bitcoind._process = {};
|
||||
bitcoind._process.kill = sinon.stub();
|
||||
bitcoind._stopSpawnedBitcoin(function(err) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#_spawnChildProcess', function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user