Run node.js application in debug with supervisor
This also works (and you don't need a separate bash script):
supervisor -- --debug app.js
supervisor -- --debug=7070 app.js
This solution will work for *nix:
Go to /usr/local/bin
or any other directory in your $PATH
$ cd /usr/local/bin
Create an executable script (say, node-debug) with the following contents
#!/bin/bash
node --debug $@
To make it executable:
$ sudo chmod 777 /usr/local/bin/node-debug
Now you can run supervisor like this:
$ supervisor -x node-debug script.js
P.S.: To round it up:
su
echo '#!/bin/bash
node --debug $@' > /usr/local/bin/node-debug
chmod 777 /usr/local/bin/node-debug
node-dev
node-dev on Github
"All arguments are passed on to the child-process. node-dev --debug server.js will debug your application, not the supervisor itself."
Create a "test.js" node.js script in $HOME/nodetest
First terminal (run node in debug mode, debug will listen on the port 5858, node-dev will reload changed files):
cd $HOME/nodetest
npm install node-dev
node_modules/.bin/node-dev --debug test.js
Second terminal (start web inspector for a WebKit based browser, inspector connects to the port 5858 of the debugger and listens on the port 8080):
cd $HOME/nodetest
npm install node-inspector
node_modules/.bin/node-inspector
Open this URL in a WebKit based browser (Chrome, Safari, etc.):
http://0.0.0.0:8080/debug?port=5858
Click on "Scripts" and set breakpoints in your code.
From the CoffeeScript site :
--nodejs The node executable has some useful options you can set, such as --debug, --debug-brk and --max-stack-size. Use this flag to forward options directly to Node.js.
I tried this and it worked:
supervisor -- --nodejs --debug app.coffee
You can add other arguments like this:
supervisor -w . -n error -- --nodejs --debug app.coffee