<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -78,7 +78,8 @@ h2. Running the jobs
 
 Run @script/generate delayed_job@ to add @script/delayed_job@. This script can then be used to manage a process which will start working off jobs.
 
-  $ ruby script/delayed_job -e production start
+  # Runs two workers in separate processes.
+  $ ruby script/delayed_job -e production -n 2 start
   $ ruby script/delayed_job -e production stop
 
 You can invoke @rake jobs:work@ which will start working off jobs. You can cancel the rake task with @CTRL-C@. </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,11 @@ require 'optparse'
 
 module Delayed
   class Command
+    attr_accessor :worker_count
+    
     def initialize(args)
       @options = {:quiet =&gt; true}
+      @worker_count = 1
       
       opts = OptionParser.new do |opts|
         opts.banner = &quot;Usage: #{File.basename($0)} [options] start|stop|restart|run&quot;
@@ -23,17 +26,23 @@ module Delayed
         opts.on('--max-priority N', 'Maximum priority of jobs to run.') do |n|
           @options[:max_priority] = n
         end
+        opts.on('-n', '--number_of_workers=workers', &quot;Number of unique workers to spawn&quot;) do |worker_count|
+          @worker_count = worker_count.to_i rescue 1
+        end
       end
       @args = opts.parse!(args)
     end
   
     def daemonize
-      Daemons.run_proc('delayed_job', :dir =&gt; &quot;#{RAILS_ROOT}/tmp/pids&quot;, :dir_mode =&gt; :normal, :ARGV =&gt; @args) do |*args|
-        run
+      worker_count.times do |worker_index|
+        process_name = worker_count == 1 ? &quot;delayed_job&quot; : &quot;delayed_job.#{worker_index}&quot;
+        Daemons.run_proc(process_name, :dir =&gt; &quot;#{RAILS_ROOT}/tmp/pids&quot;, :dir_mode =&gt; :normal, :ARGV =&gt; @args) do |*args|
+          run process_name
+        end
       end
     end
     
-    def run
+    def run(worker_name = nil)
       require File.join(RAILS_ROOT, 'config', 'environment')
       
       # Replace the default logger
@@ -42,6 +51,7 @@ module Delayed
       ActiveRecord::Base.logger = logger
       ActiveRecord::Base.clear_active_connections!
       Delayed::Worker.logger = logger
+      Delayed::Job.worker_name = &quot;#{worker_name} #{Delayed::Job.worker_name}&quot;
       
       Delayed::Worker.new(@options).start  
     rescue =&gt; e</diff>
      <filename>lib/delayed/command.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e45a3c1db2d2d014a23a5e80e0655d1b36682bb4</id>
    </parent>
  </parents>
  <author>
    <name>Patrick McKenzie</name>
    <email>patrick@bingocardcreator.com</email>
  </author>
  <url>http://github.com/collectiveidea/delayed_job/commit/17ddfb53f597e45bb59bd54376791437b452fcbc</url>
  <id>17ddfb53f597e45bb59bd54376791437b452fcbc</id>
  <committed-date>2009-05-09T06:55:53-07:00</committed-date>
  <authored-date>2009-05-08T21:51:33-07:00</authored-date>
  <message>Added ability to run multiple workers concurrently.</message>
  <tree>915e1c7c6fa9c09c4212574c462338e9d941668f</tree>
  <committer>
    <name>Brandon Keepers</name>
    <email>brandon@collectiveidea.com</email>
  </committer>
</commit>
