test.shutdown.js 829 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Module dependencies.
  3. */
  4. var spawn = require('child_process').spawn
  5. , http = require('http');
  6. require('./common');
  7. var calls = 0;
  8. // child process
  9. var child = spawn('node', [__dirname + '/support/server.js'], {
  10. customFds: [-1, -1, 2]
  11. });
  12. // listening
  13. child.stdout.on('data', function(chunk){
  14. var options = { host: 'localhost', port: 3000 };
  15. http.get(options, function(res){
  16. ++calls;
  17. res.statusCode.should.equal(200);
  18. child.kill('SIGQUIT');
  19. });
  20. http.get(options, function(res){
  21. ++calls;
  22. res.statusCode.should.equal(200);
  23. });
  24. http.get(options, function(res){
  25. ++calls;
  26. res.statusCode.should.equal(200);
  27. });
  28. http.get(options, function(res){
  29. ++calls;
  30. res.statusCode.should.equal(200);
  31. });
  32. });
  33. child.on('exit', function(){
  34. calls.should.equal(4);
  35. });