Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added worker SIGQUIT test

  • Loading branch information...
commit d4c88236b6a09cdec7d90b77b3d43c3dda6fd860 1 parent 62c4838
@tj tj authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 test/test.worker-quit.js
View
36 test/test.worker-quit.js
@@ -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();
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.