Skip to content

Commit

Permalink
worker-farm: pass explicit execArgv to workers
Browse files Browse the repository at this point in the history
Reviewed By: davidaurelio

Differential Revision: D5002197

fbshipit-source-id: 8f556626321963c103d38ec9865110a39f1a5109
  • Loading branch information
Jean Lauliac authored and facebook-github-bot committed May 4, 2017
1 parent 2de6e54 commit bc4de00
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions packager/src/JSTransformer/index.js
Expand Up @@ -38,6 +38,7 @@ function makeFarm(worker, methods, timeout, maxConcurrentWorkers) {
return workerFarm(
{
autoStart: true,
execArgv: [],
maxConcurrentCallsPerWorker: 1,
maxConcurrentWorkers,
maxCallsPerWorker: MAX_CALLS_PER_WORKER,
Expand Down
4 changes: 2 additions & 2 deletions packager/src/worker-farm/lib/farm.js
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packager/src/worker-farm/lib/fork.js
Expand Up @@ -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});
Expand Down
6 changes: 5 additions & 1 deletion packager/src/worker-farm/lib/index.js
Expand Up @@ -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)

Expand Down

0 comments on commit bc4de00

Please sign in to comment.