Skip to content

Commit

Permalink
Review notes fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Olegas committed Apr 9, 2015
1 parent ee643bd commit fd21b92
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions test/parallel/test-cluster-worker-disconnect.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var fs = require('fs');
var path = require('path');

if (cluster.isWorker) {
var http = require('http');
http.Server(function() {

}).listen(common.PORT, '127.0.0.1');

// Save flag-file on disconnect
cluster.worker.on('disconnect', function(){
fs.writeFileSync(path.join(__dirname, process.pid + ''), '');
process.exit(42);
});

} else if (cluster.isMaster) {
Expand Down Expand Up @@ -67,17 +64,10 @@ if (cluster.isWorker) {
});

// Check that the worker died
worker.once('exit', function() {
worker.once('exit', function(code) {
checks.worker.emitExit = true;
checks.worker.died = !alive(worker.process.pid);

var flagFile = path.join(__dirname, worker.process.pid + '');
checks.worker.emitDisconnectInsideWorker = fs.existsSync(flagFile);

// cleanup
if (checks.worker.emitDisconnectInsideWorker) {
fs.unlinkSync(flagFile);
}
checks.worker.emitDisconnectInsideWorker = code === 42;

process.nextTick(function() {
process.exit(0);
Expand Down

0 comments on commit fd21b92

Please sign in to comment.