LearnBoost / cluster

Node.JS multi-core server manager with plugins support.
http://learnboost.github.com/cluster
MIT License
2.29k stars 159 forks source link

os.cpus() undefined #50

Closed Hamms closed 13 years ago

Hamms commented 13 years ago

I'm using the simple example app.js you give; server.js is just var cluster = require('cluster') cluster('./app').listen(8001)

I get the following error:

$ node server.js 

node.js:116
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot read property 'length' of undefined
    at Master.start (/usr/local/lib/node/.npm/cluster/0.3.2/package/lib/master.js:393:18)
    at /usr/local/lib/node/.npm/cluster/0.3.2/package/lib/master.js:253:16
    at Master.createSocket (/usr/local/lib/node/.npm/cluster/0.3.2/package/lib/master.js:366:5)
    at Master.listen (/usr/local/lib/node/.npm/cluster/0.3.2/package/lib/master.js:250:14)
    at Object.<anonymous> (/usr/home/elijah/cluster/server.js:3:18)
    at Module._compile (module.js:373:26)
    at Object..js (module.js:379:10)
    at Module.load (module.js:305:31)
    at Function._load (module.js:271:10)
    at Array.<anonymous> (module.js:392:10)

It looks like os.cpus() is undefined in if (!this.has('workers')) { this.set('workers', os ? os.cpus().length : 1); }

tj commented 13 years ago

os should be undefined for node 0.2.x, works fine for me with both version of node :s

Hamms commented 13 years ago

I'm on node 0.4.0; is that the problem?

I should clarify; os is definitely defined, and when I sys.inspect os.cpus, I see { [Function]

  [length]: 0,
  [name]: '',
  [prototype]: { [constructor]: [Circular] },
  [caller]: null }

But it returns undefined when called.

Hamms commented 13 years ago

I went ahead and also submitted this here

tj commented 13 years ago

closing since its a node thing