-
-
Save devdatta/352787 to your computer and use it in GitHub Desktop.
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
Resque.after_fork do |job| | |
# How many jobs should we process in each fork? | |
jobs_per_fork = [ ENV['JOBS_PER_FORK'].to_i, 1 ].max | |
# Set hook to nil to prevent running this hook over | |
# and over while processing more jobs in this fork. | |
Resque.after_fork = nil | |
# Make sure we process jobs in the right order. | |
job.worker.process(job) | |
# One less than specified because the child will run a | |
# final job after exiting this hook. | |
(jobs_per_fork.to_i - 1).times do | |
job.worker.process | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment