Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arguments are passed incorrectly when using coffee script #49

Closed
szimek opened this issue Mar 8, 2012 · 8 comments
Closed

Arguments are passed incorrectly when using coffee script #49

szimek opened this issue Mar 8, 2012 · 8 comments

Comments

@szimek
Copy link

szimek commented Mar 8, 2012

Hi,

there's the following code in supervisor.js#155:

var spawnme = args ? [prog].concat(args) : [prog];

The issue with it is that coffee script expects options first and then script name:

$ coffee --help
Usage: coffee [options] path/to/script.coffee

while the code above provides script name first (prog) and then options (args).

Changing the line above to:

var spawnme = args ? args.concat[prog] : [prog];

solves the issue and allows to run node js with debugger enabled like this:

supervisor -- app.coffee --nodejs --debug

If the order in which script name and arguments should be passed depends on executable, maybe it would be possible to add an option for that (e.g. --options-first), which for coffee would be set by default.

I can write a patch for that if anybody else thinks it's a good idea :)

@iangreenleaf
Copy link
Collaborator

Hmm, if I understand correctly it's a question of setting the arguments against coffee or node, as opposed to setting them against your own application: node --node-opt app.js vs node app.js --my-opt. I think we should support both, ideally at the same time (a flaw with the --options-first style.

Right now, it's possible to do this like so:

supervisor -x 'coffee' -- --nodejs --debug app.coffee

Or, it would be possible except for a bug that's inserting a comma for some reason.

I realize this is somewhat awkward syntax. I'm open to suggestions for better ways to do it.

@szimek
Copy link
Author

szimek commented Mar 8, 2012

Thanks for the tip! Despite printing out

Starting child process with 'coffee --debug,app.coffee --nodejs'

it somehow works :) However, I'm using foreman to run the app and it doesn't like this syntax, because it fails with:

web.1     | DEBUG: Starting child process with ''coffee' --debug,app.coffee --nodejs'
web.1     | DEBUG: execvp(): No such file or directory

Anyway, I think you're right about node options vs application options.

I'm not sure about the comma bug you mentioned, but I guess that it's just displayed incorrectly - in supervisor.js#152 there's the following line:

util.debug("Starting child process with '" + exec + " " + prog + " " + args + "'");

that converts args array to a string using join(",") by default. It could be easily fixed by joining them manually:

util.debug("Starting child process with '" + exec + " " + prog + " " + args.join(" ") + "'");

@iangreenleaf
Copy link
Collaborator

Ah, cool. So I'll consider this an issue that has a workaround, but could definitely benefit from a friendlier solution.

That's weird that foreman is choking on it. You're running from a Procfile, I assume? You could ask them if that's intended behavior.

@sdeframond
Copy link

Hi, thank for the tip. I works well excepted that launching

  supervisor -e "coffee|node|js" -x coffee -- --nodejs --debug app.coffee

hangs when I modify one of the application files. I got the message DEBUG: crashing child, then nothing happens. Would it be related ?

@iangreenleaf
Copy link
Collaborator

Hmm, interesting. It looks like somehow coffeescript or the --nodejs option is causing a bug. I opened #51 to deal with that.

iangreenleaf added a commit that referenced this issue May 2, 2012
Fixes #51.

Also fixes some debugging glitches mentioned in #49.
@iangreenleaf
Copy link
Collaborator

I had another think about this. Here's my new idea, lemme know how this feels: we could offer a wildcard flag, --x-foo, where anything after the --x- gets passed in as a -- argument to the child.

supervisor --x-debug-brk server.js #=> node --debug-brk server.js
supervisor --x-node-debug-brk server.coffee #=> coffee --node-debug-brk server.coffee

I'm thinking it would either be --x-foo (to match the -x option), or --child-foo (for obvious reasons).

@Leonidaz
Copy link

not sure if this is still an issue but i was able to get going on windows without modifying supervisor code via the cli-wrapper.js

start cmd.exe /k "node-inspector"
start cmd.exe /k "node node_modules\supervisor\lib\cli-wrapper.js -w .,node_modules,node_modules/custom_modules -- ""--debug-brk ./././index.js"""

the first line is just to start the node-inspector
basically escaped the program param with double quotes: -- ""--debug-brk ./././index.js"""
make sure that the program parameter is passed in with double dash and space in front

@iangreenleaf
Copy link
Collaborator

Will track future progress on options in #123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants