Skip to content
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

Merged
merged 2 commits into from
Aug 7, 2014

Conversation

ndbroadbent
Copy link

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:

set :delayed_job_args, "--pool=*:2 --pool=mailers,tasks:1 --pool=important:2"

This will start the following workers:

  • delayed_job.0 and delayed_job.1 running any jobs
  • delayed_job.2 running jobs from the mailers and tasks queues
  • delayed_job.3 and delayed_job.4 running jobs from the important queue

Specs included.

@tyre
Copy link

tyre commented Dec 6, 2013

👍

2 similar comments
@nickgervasi
Copy link

👍

@OmarSkalli
Copy link

👍

@tyre
Copy link

tyre commented Jun 3, 2014

@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|
Copy link
Member

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.

@ndbroadbent ndbroadbent changed the title Added --pools argument, so that multiple worker pools can be defined with different queues and numbers of workers. Added --pool option, so that multiple worker pools can be defined with different queues and numbers of workers. Jul 8, 2014
@coveralls
Copy link

Coverage Status

Coverage decreased (-3.07%) when pulling ca8ede6 on ndbroadbent:multiple_queue_support into b8ecbf1 on collectiveidea:master.

@ndbroadbent
Copy link
Author

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 lib/delayed/command.rb and didn't cover all the existing options.)

albus522 added a commit that referenced this pull request Aug 7, 2014
Added --pool option, so that multiple worker pools can be defined with different queues and numbers of workers.
@albus522 albus522 merged commit 0ece42f into collectiveidea:master Aug 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants