Permalink
Browse files

Added SIGKILL worker recovery test

  • Loading branch information...
tj committed Feb 21, 2011
1 parent 60704a1 commit dbbf8f65051f13b5b69ce9faa8ff6802efd8dad0
Showing with 36 additions and 0 deletions.
  1. +36 −0 test/test.worker-kill.js
View
@@ -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, 'SIGKILL');
+ });
+});
+
+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 dbbf8f6

Please sign in to comment.