Abort requests that are taking too long; a Timeout::Error will be raised.
# Gemfile
gem "SystemTimer", :require => "system_timer", :platforms => :ruby_18
gem "rack-timeout"
# config/environment.rb
config.gem "SystemTimer", :lib => "system_timer" if RUBY_VERSION < "1.9"
config.gem "rack-timeout"
# config.ru
require 'rack/timeout'
use Rack::Timeout
Rack::Timeout.timeout = 10 # this line is optional. if omitted, default is 15 seconds.
# config/initializers/timeout.rb
Rack::Timeout.timeout = 10 # seconds
SystemTimer/timeout rely on threads. If your app or any of the libraries it depends on is not thread-safe, you may run into issues using rack-timeout.
Copyright © 2010 Caio Chassot, released under the MIT license http://github.com/kch/rack-timeout