uber-archive / nanny

Cluster management for Node processes
http://www.uber.com
MIT License
40 stars 4 forks source link

Unable to pass cmdline arguments to worker #11

Closed leizha closed 10 years ago

leizha commented 10 years ago

I was trying to start the worker with --config argument

var supervisor = new ClusterSupervisor({ exec: path.join(__dirname, "worker.js"), execArgv: [ '--config=' + path.join(__dirname, 'config/cluster.json') ], logicalIds: _.range(workerCount), createEnvironment: function(logicalId) { return _.defaults({ PROCESS_LOGICAL_ID: logicalId }, process.env); } });

It failed with

Try --help for options Error: unrecognized flag --config=/Users/leizha/Uber/ramen/server/config/cluster.json

I think the reason was that when execArgv was set, it overwrote the first argument which was worker.js

leizha commented 10 years ago

the workaround for now is

{exec: ' ', execArgv: [ 'worker.js', '--config...' ]}

kriskowal commented 10 years ago

Does the args options work instead of execArgv? The former is for arguments to your worker, and the other is arguments to Node.js itself.

leizha commented 10 years ago

nope, once I changed it to args, print process.argv in work gave me this

worker [ '/Users/leizha/.nvm/v0.10.26/bin/node', '/Users/leizha/Uber/ramen/server/node_modules/nanny/_worker' ]

kriskowal commented 10 years ago

Yeah, this is a bug. I’ll fix. I’m introducing a workerArgv option.