|
1 | 1 | 'use strict';
|
2 | 2 | const assert = require('assert');
|
3 | 3 | const { fork } = require('child_process');
|
4 |
| -const util = require('util'); |
5 | 4 | const path = require('path');
|
6 | 5 | const EventEmitter = require('events');
|
7 | 6 | const RoundRobinHandle = require('internal/cluster/round_robin_handle');
|
@@ -47,14 +46,14 @@ if (schedulingPolicy === undefined) {
|
47 | 46 | cluster.schedulingPolicy = schedulingPolicy;
|
48 | 47 |
|
49 | 48 | cluster.setupMaster = function(options) {
|
50 |
| - var settings = { |
| 49 | + const settings = { |
51 | 50 | args: process.argv.slice(2),
|
52 | 51 | exec: process.argv[1],
|
53 | 52 | execArgv: process.execArgv,
|
54 |
| - silent: false |
| 53 | + silent: false, |
| 54 | + ...cluster.settings, |
| 55 | + ...options |
55 | 56 | };
|
56 |
| - util._extend(settings, cluster.settings); |
57 |
| - util._extend(settings, options || {}); |
58 | 57 |
|
59 | 58 | // Tell V8 to write profile data for each process to a separate file.
|
60 | 59 | // Without --logfile=v8-%p.log, everything ends up in a single, unusable
|
@@ -101,15 +100,12 @@ function setupSettingsNT(settings) {
|
101 | 100 | }
|
102 | 101 |
|
103 | 102 | function createWorkerProcess(id, env) {
|
104 |
| - const workerEnv = util._extend({}, process.env); |
| 103 | + const workerEnv = { ...process.env, ...env, NODE_UNIQUE_ID: `${id}` }; |
105 | 104 | const execArgv = cluster.settings.execArgv.slice();
|
106 | 105 | const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
|
107 | 106 | const nodeOptions = process.env.NODE_OPTIONS ?
|
108 | 107 | process.env.NODE_OPTIONS : '';
|
109 | 108 |
|
110 |
| - util._extend(workerEnv, env); |
111 |
| - workerEnv.NODE_UNIQUE_ID = '' + id; |
112 |
| - |
113 | 109 | if (execArgv.some((arg) => arg.match(debugArgRegex)) ||
|
114 | 110 | nodeOptions.match(debugArgRegex)) {
|
115 | 111 | let inspectPort;
|
@@ -315,17 +311,18 @@ function queryServer(worker, message) {
|
315 | 311 |
|
316 | 312 | // Set custom server data
|
317 | 313 | handle.add(worker, (errno, reply, handle) => {
|
318 |
| - reply = util._extend({ |
319 |
| - errno: errno, |
320 |
| - key: key, |
321 |
| - ack: message.seq, |
322 |
| - data: handles.get(key).data |
323 |
| - }, reply); |
| 314 | + const { data } = handles.get(key); |
324 | 315 |
|
325 | 316 | if (errno)
|
326 | 317 | handles.delete(key); // Gives other workers a chance to retry.
|
327 | 318 |
|
328 |
| - send(worker, reply, handle); |
| 319 | + send(worker, { |
| 320 | + errno, |
| 321 | + key, |
| 322 | + ack: message.seq, |
| 323 | + data, |
| 324 | + ...reply |
| 325 | + }, handle); |
329 | 326 | });
|
330 | 327 | }
|
331 | 328 |
|
|
0 commit comments