Debugging

mde edited this page Oct 31, 2014 · 7 revisions

Debugging Geddy or a Geddy Application is simple thanks to the Webkit Debugger and node-inspector. We will only give you the steps to get started and a few links to get more information on the tools we you can use.

Debugging a Geddy Application

First install node-inspector

   npm install node-inspector -g

Run geddy

   $ geddy

When geddy starts you will see a message that includes the Process Id.

INFO Server worker running in development on port 4000 with a PID of: 3180

NOTE: If you configured geddy to use more than one worker (the default), run geddy using -w 1 this will make it easier to find the process you need to debug. Start a new terminal, send a USR1 signal to the process number found above.

$ kill -s USR1 3180

You will see the message

Hit SIGUSR1 - starting debugger agent.

debugger listening on port 5858

Now start node-inspector

   $ node-inspector &

On your browser visit http://127.0.0.1:8080/debug?port=5858. Open the Scripts panel and find controllers/main.js. Set a breakpoint inside of the index action. Hit your app's root (e.g. localhost:4000).

Debugging Geddy

If you want to debug geddy, you need to start it by calling node instead of using the geddy executable

$  node --debug-brk /usr/local/lib/node_modules/geddy/bin/cli.js 

Now run node-inspector

$ node-inspector

Visit http://127.0.0.1:8080/debug?port=5858 and you will be debugging cli.js which is Geddy's entry point.

Debugging a Geddy Application in WebStorm or IntelliJ

In short, set up your app as if you were going to deploy on Heroku or Nodejitsu.

package.json

{
  "name": "geddy_todo",
  "version": "0.0.1",
  "dependencies": {
    "geddy": "0.6.x"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

app.js

var geddy = require('geddy');

geddy.start();

Note: Since you require('geddy'), make sure it's installed as a local module (npm install geddy).

Note2: debugging in WebStorm/IntelliJ will not work when using startCluster (the node cluster module)

In WebStorm/IntelliJ, in your Run/Debug Configuration for the Node.js app be sure to add an the environment variable GEDDY_ENVIRONMENT and set it to 'development' or 'test' if you want to run your tests.

More