Created
July 24, 2014 23:04
-
-
Save joncode/9dcb021e2ef11c632b14 to your computer and use it in GitHub Desktop.
Retry code for resque jobs
This file contains hidden or 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 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