Comparing version 1.1.1 to 1.2.0
@@ -11,3 +11,2 @@ 'use strict'; | ||
var repl; | ||
var manualRestart; | ||
var shutdown; | ||
@@ -43,2 +42,4 @@ | ||
workers = toFork.map(function(what) { | ||
var manualRestart; | ||
return { | ||
@@ -147,2 +148,5 @@ id: forks.push(null) - 1, | ||
repl = require('./repl.js')(masterWorker, workers, opts.repl); | ||
repl.on('listening', function emitREPLAddress() { | ||
masterWorker.emit('repl', this.address()); | ||
}); | ||
} | ||
@@ -274,3 +278,8 @@ | ||
forks[clusterWorker.id].once('exit', function(code, signal) { | ||
if (code === 0 && !signal) { | ||
// if `signal` is defined, it means | ||
// - master killed the worker | ||
// - someone from the outside killed the worker | ||
// In both cases, we do not want to restart the worker | ||
// If you want to restart the worker, use the REPL | ||
if (code === 0 || signal) { | ||
return; | ||
@@ -277,0 +286,0 @@ } |
{ | ||
"name": "forkie", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "forkie likes your forks", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -434,2 +434,23 @@ describe('creating a graceful master process', function () { | ||
describe('when fork exits with 1 and a signal was sent', function(done) { | ||
beforeEach(function () { | ||
forks[0].emit('exit', 1, 'SIGKILL'); | ||
// restart timeout | ||
this.clock.tick(1000); | ||
}); | ||
it('do not call fork again', function() { | ||
expect(fakeCp.fork).to.be.calledOnce; | ||
}); | ||
it('does not sends a restarted event', function() { | ||
expect(workerEmit).to.not.be.calledWithExactly('worker restarted', { | ||
id: 0, | ||
toFork: 'a-restarted-module.js', | ||
restarts: { manual: 0, automatic: 1 } | ||
}); | ||
}); | ||
}); | ||
describe('when fork exits with 0', function(done) { | ||
@@ -440,7 +461,7 @@ beforeEach(function () { | ||
it('do not call fork again', function() { | ||
it('does not call fork again', function() { | ||
expect(fakeCp.fork).to.be.calledOnce; | ||
}); | ||
it('sends a restarted event', function() { | ||
it('does not sends a restarted event', function() { | ||
expect(workerEmit).to.not.be.calledWithExactly('worker restarted', { | ||
@@ -447,0 +468,0 @@ id: 0, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40219
1109