Created
May 22, 2012 14:58
-
-
Save jrallison/2769602 to your computer and use it in GitHub Desktop.
Force timeout before the unicorn worker gets reaped
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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