views:

169

answers:

3

Today, for no reason, my rails(2.1.0) application is very slow or even not responding. It happens intermittently. So sometimes it works but again it doesn't work.

When it doesn't work, I can't even load 'script/console production'. I want to know where it's stuck. How do I load console step-by-step so that I can know which part causes the problem?

Thanks.

Sam

A: 

When all else fails, you should be able to use strace to debug what the script/application is actually doing. Note that this should only be one of the last resorts as it produces extremely verbose information (and also mostly limited to I/O actions).

Try using 'strace script/console production' for example

Zsol
+1  A: 

If you are able, try temporarily removing all plugins/gems and see if the app will boot. One of those is likely the problem.

The script/console file contains this.

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'

You can find the commands/console file here for Rails 2.1.

I recommend loading up irb and trying to load your app from there.

require 'config/boot'

If that works, then try stepping through the rest of the mentioned commands/console script to find out which part is the problem.

If the boot file won't load, take a look at that config/boot.rb file to see if you can determine which part isn't working. Good luck!

ryanb
+1  A: 

You could be running out of memory on your server and so the machine can't respond to you. If you are running mongrel then get monit onto it to limit the memory it can use and restart where necessary.

If you are using Passenger, try limiting the amount of instances, and if you have already done that look up a script that kills passenger instances when too big via a cron job.

If it's not a memory issue then I'd probably need more information.

railsninja
Yeah. It turned out that someone was running a mean script which took most of the server's resources.
Sam Kong