Skip to content
Browse files

Added queue arguments to the jobs:work rake tast, and the command-lin…

…e daemon starter. Updated README.
  • Loading branch information...
1 parent 43b0279 commit f7eab0aacc401c644f36e67ed46d06e108c81dfd @bracken bracken committed Feb 18, 2010
Showing with 9 additions and 2 deletions.
  1. +5 −1 README.textile
  2. +3 −0 lib/delayed/command.rb
  3. +1 −1 lib/delayed/tasks.rb
View
6 README.textile
@@ -107,11 +107,15 @@ $ RAILS_ENV=production script/delayed_job stop
# Runs two workers in separate processes.
$ RAILS_ENV=production script/delayed_job -n 2 start
$ RAILS_ENV=production script/delayed_job stop
+
+# Specify the queue the worker should work out of with -q/--queue
+$ script/delayed_job start --queue=my_queue
</pre>
Workers can be running on any computer, as long as they have access to the database and their clock is in sync. Keep in mind that each worker will check the database at least every 5 seconds.
-You can also invoke @rake jobs:work@ which will start working off jobs. You can cancel the rake task with @CTRL-C@.
+You can also invoke @rake jobs:work@ which will start working off jobs. You can cancel the rake task with @CTRL-C@.
+You can specify the queue for the rake task to use with an environment variable: @QUEUE=my_queue rake jobs:work@
h2. Custom Jobs
View
3 lib/delayed/command.rb
@@ -31,6 +31,9 @@ def initialize(args)
opts.on('-n', '--number_of_workers=workers', "Number of unique workers to spawn") do |worker_count|
@worker_count = worker_count.to_i rescue 1
end
+ opts.on('-q', '--queue=queue_name', "The name of the queue for the workers to pull work from") do |queue|
+ @options[:queue] = queue
+ end
end
@args = opts.parse!(args)
end
View
2 lib/delayed/tasks.rb
@@ -10,6 +10,6 @@
desc "Start a delayed_job worker."
task :work => [:merb_env, :environment] do
- Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
+ Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY'], :queue => ENV['QUEUE']).start
end
end

0 comments on commit f7eab0a

Please sign in to comment.
Something went wrong with that request. Please try again.