Created
June 25, 2012 01:03
-
-
Save mikeabiezzi/2985827 to your computer and use it in GitHub Desktop.
Patch to Resque interpreting TERM as a soft shutdown.
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
# Registers the various signal handlers a worker responds to. | |
# | |
# TERM: Shutdown immediately, stop processing jobs. | |
# INT: Shutdown immediately, stop processing jobs. | |
# QUIT: Shutdown after the current job has finished processing. | |
# USR1: Kill the forked child immediately, continue processing jobs. | |
# USR2: Don't process any new jobs | |
# CONT: Start processing jobs again after a USR2 | |
def register_signal_handlers | |
trap('TERM') { shutdown! } | |
trap('INT') { shutdown! } | |
begin | |
trap('QUIT') { shutdown } | |
trap('USR1') { kill_child } | |
trap('USR2') { pause_processing } | |
rescue ArgumentError | |
warn "Signals QUIT, USR1, USR2, and/or CONT not supported." | |
end | |
log! "Registered signals" | |
end |
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
trap('TERM') { shutdown! } |
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
trap('TERM') { shutdown } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment