Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run node.js application in debug with supervisor

I am using supervisor to auto-reload my node.js, e.g.

supervisor -w . app.js

However I can't work out how to get supervisor to run the node.js process in debug, e.g. the equivalent to

node --debug app.coffee

Anyone got any ideas?

like image 217
James Hollingworth Avatar asked Jun 24 '11 12:06

James Hollingworth


People also ask

How do I run a node js project in debug mode?

Open the starting file (typically index. js ), activate the Run and Debug pane, and click the Run and Debug Node. js (F5) button. The debugging screen is similar to Chrome DevTools with a Variables, Watch, Call stack, Loaded scripts, and Breakpoints list.


2 Answers

This also works (and you don't need a separate bash script):

supervisor -- --debug app.js
supervisor -- --debug=7070 app.js
like image 121
Jesper Avatar answered Oct 16 '22 07:10

Jesper


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
like image 20
TEHEK Avatar answered Oct 16 '22 05:10

TEHEK