Unfortunately my previous solution was only temporary, after a while I mentioned that mongrels are eating the memory and hanging.

What is sure is that rails is using up to too much memory and crashes, it even seams to be a known problem, (wonder why I have not found any references before).

How to ? . Yes use GOD. You can with gem

 server ~ / $ gem install god

The configuration files are in ruby so this will not be so difficult to understand. The official website of god contains very good example that I will copy here.

server ~ / $ cat /etc/mongrel_cluster/redmine.god
RAILS_ROOT = "/opt/redmine"
RAILS_ENV = "production"
 
%w{8000 8001 8002}.each do |port|
  God.watch do |w|
    w.name = "redmine-mongrel-#{port}"
    w.interval = 30.seconds # default      
    w.start = "mongrel_rails start -c ${RAILS_ROOT} -p #{port} \
      -P #{RAILS_ROOT}/log/mongrel.#{port}.pid  -d"
    w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
    w.restart = "mongrel_rails restart -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
    w.start_grace = 10.seconds
    w.restart_grace = 10.seconds
    w.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid")
 
    w.behavior(:clean_pid_file)
 
    w.start_if do |start|
      start.condition(:process_running) do |c|
        c.interval = 5.seconds
        c.running = false
      end
    end
 
    w.restart_if do |restart|
      restart.condition(:memory_usage) do |c|
        c.above = 150.megabytes
        c.times = [3, 5] $ 3 out of 5 intervals
      end
 
      restart.condition(:cpu_usage) do |c|
        c.above = 50.percent
        c.times = 5
      end
    end
 
    $ lifecycle
    w.lifecycle do |on|
      on.condition(:flapping) do |c|
        c.to_state = [:start, :restart]
        c.times = 5
        c.within = 5.minute
        c.transition = :unmonitored
        c.retry_in = 10.minutes
        c.retry_times = 5
        c.retry_within = 2.hours
      end
    end
  end
end

To test simply run (this command will not daemonize)

server ~ / $ god -c /etc/mongrel_cluster/redmine.god -D

If everything is you expected than run

server ~ / $ god -c /etc/mongrel_cluster/redmine.god

God will monitor your and in case of heavy memory usage will restart the processes, read the code for more conditions.