Skip to content

Commit

Permalink
Added worker SIGQUIT test
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Feb 21, 2011
1 parent 62c4838 commit d4c8823
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/test.worker-quit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

/**
* Module dependencies.
*/

var cluster = require('../')
, http = require('http');

require('./common');

var server = http.createServer(function(req, res){
res.writeHead(200);
res.end('Hello World');
});

cluster = cluster(server)
.set('workers', 1)
.listen(3000);

cluster.on('listening', function(){
http.get({ host: 'localhost', port: 3000 }, function(res){
res.statusCode.should.equal(200);

// kill the worker
var pid = cluster.children[0].proc.pid;
process.kill(pid, 'SIGQUIT');
});
});

cluster.on('worker killed', function(worker){
worker.id.should.equal(0);
http.get({ host: 'localhost', port: 3000 }, function(res){
res.statusCode.should.equal(200);
cluster.close();
});
});

0 comments on commit d4c8823

Please sign in to comment.