Skip to content

Instantly share code, notes, and snippets.

@jrallison
Created May 22, 2012 14:58
Show Gist options
  • Save jrallison/2769602 to your computer and use it in GitHub Desktop.
Save jrallison/2769602 to your computer and use it in GitHub Desktop.
Force timeout before the unicorn worker gets reaped
class ApplicationController < ActionController::Base
around_filter :force_timeout
protected
def force_timeout(&block)
begin
# Make sure the timeout here is less than
# the timeout configured for unicorn reaping.
# Here we set a timeout of 10 seconds and
# unicorn is configured to reap after 15 seconds.
status = Timeout::timeout(10) { yield }
rescue Timeout::Error => e
raise "Timed out request!"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment