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

wrong server root dir with wrapper scripts like nodules #104

Open Waquo opened 13 years ago

Waquo commented 13 years ago

When running a script with nodules like this, nodules script.js instead of this, node script js this code in master.js

  // grab server root
  this.cmd = process.argv.slice(1);
  this.dir = dirname(this.cmd[0]); 

always grabs the first parameter passed to node, even though that is nodules.

Assuming the path to nodules is /node/bin/nodules, this will lead to paths being resolved to "/node/bin/./logs/master.log" or some such.

I suppose require.js would lead to the same problem as nodules.

tj commented 13 years ago

what's nodules?

Waquo commented 13 years ago

https://github.com/kriszyp/nodules

Nodules has to overwrite the global require function, it is used like this:

Instead of just node runme.js you run node /path/to/nodules.js runme.js and all code run by runme.js uses the require() provided by nodules.

nodules runme.js is a shorthand for this.

I didn't test it, but require.js replaces require() the same way, so i guess it would result in the same problem.

tj commented 13 years ago

hm, yeah I would probably just tell them not to do that haha, but yeah we just need to make sure we run the same command that spawned the master originally

Waquo commented 13 years ago

I don't think calling the command is the issue.

If calling node /path/to/nodules.js runme.js worked the first time, "/path/to/nodules.js runme.js" should work just fine as a command. The problem is that logfiles etc. should be placed in /path/to/runme.js, not /path/to/nodules.js.

I suppose the most straightforward solution would be to allow set()ing the server path as an option, with the current solution as a default. This way users of wrapper-scripts like nodules or require.js could at least fix this issue if it comes up.