koudelka/cluster — pull request #1 by alexkwolfe (2011-11-16 23:54:46+00:00)
Title: Spawned children should use the same working directory as the parent. 

If the process.cwd() function is used to set the working directory on a cluster, the workers are started in the directory that contains the start script, rather than the cwd of the master.

````javascript

// if this script is in a different directory than the appFile,
// then the workers fail to load the appFile. This is so because
// the worker's working directory is set to the directory
// containing this script.

// This fix sets the workers' working directory as
// determined by the master process.

var appFile = process.cwd() + "/" + process.argv[2]
, app = require(process.argv[2]),
, path = require('path');

cluster(app)
.set('working directory', path.dirname(appFile))
.use(cluster.pidfiles(path.dirname(appFile) + "/pids"))
.use(cluster.cli())
.use(cluster.debug())
.listen(8080);
````