worker-farm: pass explicit execArgv to workers

Reviewed By: davidaurelio

Differential Revision: D5002197

fbshipit-source-id: 8f556626321963c103d38ec9865110a39f1a5109
This commit is contained in:
Jean Lauliac 2017-05-04 10:19:33 -07:00 коммит произвёл Facebook Github Bot
Родитель 2de6e546bd
Коммит bc4de008d3
4 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -38,6 +38,7 @@ function makeFarm(worker, methods, timeout, maxConcurrentWorkers) {
return workerFarm(
{
autoStart: true,
execArgv: [],
maxConcurrentCallsPerWorker: 1,
maxConcurrentWorkers,
maxCallsPerWorker: MAX_CALLS_PER_WORKER,

Просмотреть файл

@ -27,7 +27,7 @@ const extend = require('xtend')
, ProcessTerminatedError = require('errno').create('ProcessTerminatedError')
, MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError')
function Farm (options: {}, path: string) {
function Farm (options: {+execArgv: Array<string>}, path: string) {
this.options = extend(DEFAULT_OPTIONS, options)
this.path = path
this.activeCalls = 0
@ -108,7 +108,7 @@ Farm.prototype.onExit = function (childId) {
Farm.prototype.startChild = function () {
this.childId++
var forked = fork(this.path)
var forked = fork(this.path, {execArgv: this.options.execArgv})
, id = this.childId
, c = {
send : forked.send

Просмотреть файл

@ -14,10 +14,11 @@
const childProcess = require('child_process');
const childModule = require.resolve('./child/index');
function fork(forkModule: string) {
function fork(forkModule: string, options: {|+execArgv: Array<string>|}) {
const child = childProcess.fork(childModule, {
env: process.env,
cwd: process.cwd(),
execArgv: options.execArgv,
});
child.send({module: forkModule});

Просмотреть файл

@ -14,7 +14,11 @@ const Farm = require('./farm')
var farms = [] // keep record of farms so we can end() them if required
function farm(options: {}, path: string, methods: Array<string>): {[name: string]: Function} {
function farm(
options: {+execArgv: Array<string>},
path: string,
methods: Array<string>,
): {[name: string]: Function} {
var f = new Farm(options, path)
, api = f.setup(methods)