test.restart-env.js 711 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Module dependencies.
  3. */
  4. var cluster = require('../')
  5. , http = require('http')
  6. , assert = require('assert');
  7. require('./common');
  8. var server = http.createServer(function(req, res){
  9. res.writeHead(200);
  10. res.end('Hello World');
  11. });
  12. cluster = cluster(server)
  13. .listen(3001);
  14. if (cluster.isChild) {
  15. process.cwd().should.include.string('cluster/test');
  16. cluster.on('listening', function(){
  17. assert.equal(require.paths.join(':'), process.env.REQUIRE_PATHS);
  18. assert.equal(process.env.FOO, 'bar');
  19. cluster.close();
  20. });
  21. } else {
  22. process.env.REQUIRE_PATHS = require.paths.join(':');
  23. process.env.FOO = 'bar';
  24. cluster.on('listening', function(){
  25. cluster.restart();
  26. });
  27. }