Debugging NodeJS with Google Chrome DevTools

If you're a JS nerd then surely you've heard about the awesomeness of Nodejs. It's uses  Event-driven I/O server-side JavaScript environment based on Google's V8 engine which Chrome uses. While playing around it, I just stumbled upon an excellent video tutorial to debug node js apps with Chrome's in-built dev-tools, which is superb. Check it out... 

Just a NOTE from the video:

node debug app.js  // Attaches the debugger, does not break.
node debug-brk app.js  // Breaks before the first line of the code.
kill -s USR1 node_PID  // Useful when you want to attach debugger without restarting the Node process.

The UNIX "Kill" command is used to send a signal "USR1" with "-s" switch.
USR1 and USR2 are signals sent to a process to indicate user-defined conditions. "USR1 is also often used to tell an application to reload config files; for example, sending the Apache HTTP Server a USR1, will ask the server to stop allowing new connections, wait for the current ones to die, reread the config files, re-open its log files, and restart the server, allowing for relatively smooth in-production changes. In Nodejs USR1 is used to attach a debugger to the running process." - Quoted from Wikipedia

0 comments:

Post a Comment