GDB is a great xNix debugger than is hugely useful into tracking down why a ruby process is hung. Below is a very simple how-to.
1. Install GDB
This is different between operating system. On Ubuntu, it is as simple as:
sudo apt-get install gdb
2. Find the hung process id
It will typically be the far left number associated with process you are looking for.
ps aux | grep ruby
3. Point GDB at that process
Once started you will see a lot of text scroll past.
gdb -p <process-id>
4. Print the backtrace
This is the part where you find what you are looking for.
bt
While this may look a little cryptic, it is a C backtrace and will tell you exactly where things are seizing. In this example it was a long running profiling tool that locked things up.
5. Go forth and fix your code
Now you just need to quit out of GDB; thank the world for its existance and go fix your code.
quit
Even better - http://weblog.jamisbuck.org/2006/9/22/inspecting-a-live-ruby-process
ReplyDelete