mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
cluster: add cwd to cluster.settings
This commit allows cluster workers to be created with configurable working directories. Fixes: https://github.com/nodejs/node/issues/16388 PR-URL: https://github.com/nodejs/node/pull/18399 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
3 files changed
+25
No files matched your search
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const cluster = require('cluster');
|
||||
|
||||
if (cluster.isMaster) {
|
||||
common.refreshTmpDir();
|
||||
|
||||
assert.strictEqual(cluster.settings.cwd, undefined);
|
||||
cluster.fork().on('message', common.mustCall((msg) => {
|
||||
assert.strictEqual(msg, process.cwd());
|
||||
}));
|
||||
|
||||
cluster.setupMaster({ cwd: common.tmpDir });
|
||||
assert.strictEqual(cluster.settings.cwd, common.tmpDir);
|
||||
cluster.fork().on('message', common.mustCall((msg) => {
|
||||
assert.strictEqual(msg, common.tmpDir);
|
||||
}));
|
||||
} else {
|
||||
process.send(process.cwd());
|
||||
process.disconnect();
|
||||
}
|
||||
Reference in new issue
Block a user