문제

node can be run with a debug parameter like this

$ node --debug src/file.js

I can also pass that parameter through the coffee-script binary like this

$ coffee --nodejs --debug src/file.coffee

Which works. But things get more difficult when I involve supervisor. Running coffee scripts is no problem:

$ supervisor -w src src/file.coffee

But I want to debug the coffee scripts that I'm running with supervisor. How can I send arguments such as --debug through supervisor? I tried setting the executable to a string with the arguments like this:

$ supervisor -w src -x "coffee --nodejs --debug" src/server.coffee

Which produced an infinitely repeating error message saying

DEBUG: Starting child process with 'coffee --nodejs --debug src/server.coffee'
DEBUG: execvp(): No such file or directory

Which is odd, because running coffee --nodejs --debug src/server.coffee in the terminal works.

So how can I send arguments through supervisor?


Edit: I want to expand my question with mentioning that I've now tried using nodemon as well. It seems nodemon is considered preferable to node-supervisor, so I'll accept any answer that explains how to pass --debug to the node process when launching coffee scripts through nodemon


Edit: Here's the output from nodemon. Clearly the arguments are not passed in the same order :-(

$ nodemon -w src -x coffee --nodejs --debug src/server.coffee
15 Jan 03:41:56 - [nodemon] v0.6.5
15 Jan 03:41:56 - [nodemon] watching: /foo/bar/server/src
15 Jan 03:41:56 - [nodemon] running --debug
15 Jan 03:41:56 - [nodemon] starting `coffee --debug --nodejs src/server.coffee`

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^

Error: unrecognized option: --debug
도움이 되었습니까?

해결책

actually, it turned out to be a bug :)

The short way:

nodemon --debug -w src src/server.coffee

Or (where --nodejs and --debug are included as the exec)

nodemon -x "coffee --nodejs --debug" -w src src/server.coffee

Or (looks nicer than above)

nodemon -x coffee --nodejs --debug -w src src/server.coffee

(all on nodemon 0.6.6)

다른 팁

You can use -- with supervisor. Not sure if this would work with the -x syntax though:

supervisor -w src -- coffee.js --nodejs --debug src/server.coffee

From a quick review of supervisor, it look like it passes all arguments as arguments to the script itself, so you'll want to use nodemon.

Nodemon picks out it's own arguments, but otherwise they are passed to node. In the current version, arguments after the js/coffee file are preserved, and arguments before the JS file have their order inverted, so try this.

nodemon -w src -x coffee --debug --nodejs src/server.coffee

Of course, it looks like you noticed that too :P https://github.com/remy/nodemon/issues/54

So yeah, the ordering issue is a bug that hopefully will get fixed.

It turns out the problem was that the arguments are simply passed in the reverse order. The following works

$ nodemon --debug --nodejs -w src -x coffee src/server.coffee

I have also fixed the problem and sent a pull request to the author at github

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top