Skip to content

Instantly share code, notes, and snippets.

@joncode
Created July 24, 2014 23:04
Show Gist options
  • Select an option

  • Save joncode/9dcb021e2ef11c632b14 to your computer and use it in GitHub Desktop.

Select an option

Save joncode/9dcb021e2ef11c632b14 to your computer and use it in GitHub Desktop.
Retry code for resque jobs
module RetryOnTermJob
def around_perform_retry_on_term(*args)
begin
yield *args
rescue Exception => e
if e.message =~ /SIGTERM/
# when a worker `extend`s this class, self is that worker class
Resque.enqueue(self, *args)
else
raise
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment