Debugging rails (in mongrel and passenger)
If you are using mongrel, the it is super easy to get to the debug console by just starting the server with the debugger option and inserting breakpoints in the code.
script/server --debugger or script/server -u ....somewhere in the code.... debugger ....more code...........
And you would definitely want to tweak the debugger with some options by putting the following in .rdebugrc or issuing them on the debugger console.
# you dont have to do something like "p your_command" set autoeval # reloads the source set autoreload
When you are running your app with phusion passenger, then the above technique doesn’t work, because the thread runs in background and even having this in your code has no effect during the execution of the code:
.... somewhere in the code... require 'ruby-debug' debugger ... more code....
But wait, there is hope: here is a great post on how to debug remotely using ruby-debug.
The other option that i tried was using hijack gem, but i didn’t quite like this option. Reasons being, it takes quite a while for the process to be hijacked and then when it finally did, it just couldn’t find the objects and classes that the original instance had. I tried it on a frozen rails 2.0.2 app, and i am not going to try it on a newer version because the other two options seem much better.
So yes, you can use debugger with phusion passenger and it is really easy, just as easy as using debugger with mongrel.