Well, this was a dumb mistake on my part. Just in case anyone else encounters it, the problem was that our start script had been updated to use node-dev, unbeknownst to me. Node-dev does not play nice with cluster:
https://github.com/fgnass/node-dev/issues/43 Using node directly made things work beautifully. -Casey- On Monday, December 17, 2012 4:14:39 PM UTC-8, Casey Huggins wrote: > > I am curious if anyone has encountered an issue I am currently dealing > with in the Node Cluster module. Following the guide, I have code that > looks like this: > > *if* (cluster.isMaster) { > console.log(require('util').inspect(process.env)); > *var* workerCount = settings.app.WORKERS || 1; > *for* (*var* i = 0; i < workerCount; i++) { > cluster.fork(); > } > } *else* { > *var* app = exports.createServer(); > app.listen(settings.app.PORT); > } > > Unfortunately, there appears to be some trouble in the child forking > process. Every child thinks that is master, which then creates another > forked child. I dug in to the source here: > https://github.com/joyent/node/blob/v0.8.8/lib/cluster.js. It seems that > NODE_UNIQUE_ID is never being correctly set in the child environment, and > thus each child thinks it is master. Here is the relevant source: > > var envCopy = util._extend({}, env); > envCopy['NODE_UNIQUE_ID'] = this.id; > if (isObject(customEnv)) { > envCopy = util._extend(envCopy, customEnv); > } > > // fork worker > this.process = fork(settings.exec, settings.args, { > 'env': envCopy, > 'silent': settings.silent, > 'execArgv': settings.execArgv > }); > > > I verified that cluster.Worker.id is set to 1 after the fork call, but > that the created child process.env does not have NODE_UNIQUE_ID. Has > anyone seen anything like this before? Here are some details of my current > operating env: > > node 0.8.8 > express 3.0.4 > OSX 10.7.4 > > > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
