if (process.env.NODE_DEBUG && /cluster/.test(process.env.NODE_DEBUG)) {
debug = function(x) {
var prefix = process.pid + ',' +
- (process.env.NODE_WORKER_ID ? 'Worker' : 'Master');
+ (process.env.NODE_UNIQUE_ID ? 'Worker' : 'Master');
console.error(prefix, x);
};
} else {
var timers = require('timers');
var util = require('util');
var assert = require('assert');
+var cluster;
function noop() {}
function listen(self, address, port, addressType, backlog) {
- if (process.env.NODE_UNIQUE_ID) {
- var cluster = require('cluster');
+ if (!cluster) cluster = require('cluster');
+
+ if (cluster.isWorker) {
cluster._getServer(self, address, port, addressType, function(handle) {
self._handle = handle;
self._listen2(address, port, addressType, backlog);
if (process.env.NODE_UNIQUE_ID) {
var cluster = NativeModule.require('cluster');
cluster._setupWorker();
+
+ // Make sure it's not accidentally inherited by child processes.
+ delete process.env.NODE_UNIQUE_ID;
}
var Module = NativeModule.require('module');
var assert = require('assert');
var cluster = require('cluster');
+assert.equal('NODE_UNIQUE_ID' in process.env, false,
+ 'NODE_UNIQUE_ID should be removed on startup');
+
function forEach(obj, fn) {
Object.keys(obj).forEach(function(name, index) {
fn(obj[name], name, index);
else if (cluster.isMaster) {
- assert.equal('NODE_UNIQUE_ID' in process.env, false,
- 'cluster.isMaster should not be true when NODE_UNIQUE_ID is set');
-
var checks = {
cluster: {
events: {