-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added --pool option, so that multiple worker pools can be defined with different queues and numbers of workers. #606
Added --pool option, so that multiple worker pools can be defined with different queues and numbers of workers. #606
Conversation
👍 |
2 similar comments
👍 |
👍 |
@collectiveidea @albus522 Any feedback on this PR? |
@@ -61,6 +63,9 @@ def initialize(args) | |||
opts.on('--queue=queue', "Specify which queue DJ must look up for jobs") do |queue| | |||
@options[:queues] = queue.split(',') | |||
end | |||
opts.on('--pools=queue1,queue2:workers/queue3:workers', "Specify queues and number of workers for multiple worker pools") do |pools| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/
is an odd separator. I think I would prefer multiple --pool
flags for multiple worker pools. OptParse will simply run this block for each time --pool
is used in the arguments.
So something more like (note singular)
--pool=queue1[,queue2][:worker_count]
worker_count defaulting to 1 if not specified.
…with different queues and number of workers.
Sorry for the delay @albus522 , I've updated the PR with your proposed changes. (The tests are all passing, and the coverage actually increased... I just added new specs for |
Added --pool option, so that multiple worker pools can be defined with different queues and numbers of workers.
We needed this so that we could restart multiple workers with different queues with one command via capistrano, and also so that our delayed job pids are consistent with our monit scripts. Running a separate restart command for each worker pool is very time-consuming, since the Rails environment needs to be loaded n times.
As an example, you can now add this to capistrano, to restart 3 different "pools" of workers:
This will start the following workers:
delayed_job.0
anddelayed_job.1
running any jobsdelayed_job.2
running jobs from the mailers and tasks queuesdelayed_job.3
anddelayed_job.4
running jobs from the important queueSpecs included.