Last active
August 29, 2015 14:00
-
-
Save hoan006/11281124 to your computer and use it in GitHub Desktop.
Resque stale jobs? Put a timeout for each possible one.
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
module CheckResqueJobTimeout | |
def self.included(klass) | |
klass.class_eval do | |
def self.perform_with_timeout(*args) | |
Timeout.timeout(120) do | |
perform_without_timeout(*args) | |
end | |
end | |
class << self | |
alias_method_chain :perform, :timeout | |
end | |
end | |
end | |
end | |
class SomeWorker | |
@queue = :some_worker | |
def self.perform | |
# some jobs that are stuck, such as uploading file to S3 | |
end | |
# This module will make your job fail instead of hanging your worker process forever | |
include CheckResqueJobTimeout | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment