<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/backgroundrb/bdrb_start_stop.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,9 @@
 2008-09-07  hemant kumar  &lt;hemant@shire.com&gt;
 
+        * Fix environment loading issues.
+
+        * Patch by Kieran P for disabling persistent job queue and its polling.
+
         * Commit patch by P Baker, related to scheduling a persistent task at specified time. For example:
         MiddleMan(:hello_worker).enq_some_task(:arg =&gt; &quot;hello_world&quot;,
                         :job_key =&gt; &quot;boy&quot;,:scheduled_at =&gt; (Time.now + 1.hour))</diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ require 'rake/testtask'
 require 'rake/rdoctask'
 require 'spec/rake/spectask'
 require 'rake/contrib/sshpublisher'
+require &quot;darkfish-rdoc&quot;
 
 desc 'Default: run unit tests.'
 task :default =&gt; :test
@@ -31,14 +32,19 @@ desc 'Generate documentation for the backgroundrb plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'doc/output/manual'
   rdoc.title    = 'Backgroundrb'
-  rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
+  #rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
   rdoc.rdoc_files.include('README')
   rdoc.rdoc_files.include('LICENSE')
   rdoc.rdoc_files.include('lib/*.rb')
   rdoc.rdoc_files.include('lib/backgroundrb/*.rb')
   rdoc.rdoc_files.include('server/*.rb')
   rdoc.rdoc_files.include('server/lib/*.rb')
-  rdoc.template = 'jamis'
+  #rdoc.template = 'jamis'
+  rdoc.options += [
+                   '-SHN',
+                   '-f', 'darkfish',  # This is the important bit
+                  ]
+
 end
 
 module Rake</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@ require &quot;backgroundrb/bdrb_conn_error&quot;
 require &quot;backgroundrb/rails_worker_proxy&quot;
 require &quot;backgroundrb/bdrb_connection&quot;
 require &quot;backgroundrb/bdrb_cluster_connection&quot;
-
+require &quot;backgroundrb/bdrb_start_stop&quot;
 MiddleMan = BackgrounDRb::ClusterConnection.new
 
 </diff>
      <filename>lib/backgroundrb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,9 @@
 module BackgrounDRb
+  # A Worker proxy, which uses +method_missing+ for delegating method calls to the workers
   class RailsWorkerProxy
     attr_accessor :worker_name, :worker_method, :data, :worker_key,:middle_man
 
+    # create new worker proxy
     def initialize(p_worker_name,p_worker_key = nil,p_middle_man = nil)
       @worker_name = p_worker_name
       @middle_man = p_middle_man
@@ -40,14 +42,17 @@ module BackgrounDRb
       end
     end
 
+    # enqueue tasks to the worker pool
     def enqueue_task options = {}
       BdrbJobQueue.insert_job(options)
     end
 
+    # remove tasks from the worker pool
     def dequeue_task options = {}
       BdrbJobQueue.remove_job(options)
     end
 
+    # invoke method on worker
     def run_method host_info,method_name,worker_options = {}
       result = []
       connection = choose_connection(host_info)
@@ -75,11 +80,14 @@ module BackgrounDRb
       return_result(result)
     end
 
+    # choose a backgroundrb server connection and invoke worker method on it.
     def invoke_on_connection connection,method_name,options = {}
       raise NoServerAvailable.new(&quot;No BackgrounDRb is found running&quot;) unless connection
       connection.send(method_name,options)
     end
 
+    # get results back from the cache. Cache can be in-memory worker cache or memcache
+    # based cache
     def ask_result job_key
       options = compact(:worker =&gt; worker_name,:worker_key =&gt; worker_key,:job_key =&gt; job_key)
       if BDRB_CONFIG[:backgroundrb][:result_storage] == 'memcache'
@@ -90,26 +98,38 @@ module BackgrounDRb
       end
     end
 
+    # return runtime information about worker
     def worker_info
       t_connections = middle_man.backend_connections
       result = t_connections.map { |conn| conn.worker_info(compact(:worker =&gt; worker_name,:worker_key =&gt; worker_key)) }
       return_result(result)
     end
 
+    # generate worker key
     def gen_key options
       key = [options[:worker],options[:worker_key],options[:job_key]].compact.join('_')
       key
     end
 
+    # return result from memcache
     def return_result_from_memcache options = {}
       middle_man.cache[gen_key(options)]
     end
 
+    # reset result within memcache for given key
+    def reset_memcache_result(job_key,value)
+      options = compact(:worker =&gt; worker_name,:worker_key =&gt; worker_key,:job_key =&gt; job_key)
+      key = gen_key(options)
+      middle_man.cache[key] = value
+      value
+    end
+
     def return_result result
       result = Array(result)
       result.size &lt;= 1 ? result[0] : result
     end
 
+    # delete a worker
     def delete
       middle_man.backend_connections.each do |connection|
         connection.delete_worker(compact(:worker =&gt; worker_name, :worker_key =&gt; worker_key))
@@ -117,6 +137,7 @@ module BackgrounDRb
       return worker_key
     end
 
+    # choose a worker
     def choose_connection host_info
       case host_info
       when :all; middle_man.backend_connections
@@ -126,6 +147,7 @@ module BackgrounDRb
       end
     end
 
+    # helper method to compact a hash and for getting rid of nil parameters
     def compact(options = { })
       options.delete_if { |key,value| value.nil? }
       options</diff>
      <filename>lib/backgroundrb/rails_worker_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,45 +26,14 @@ require RAILS_HOME + &quot;/config/environment&quot;
 require &quot;bdrb_job_queue&quot;
 require &quot;backgroundrb_server&quot;
 
-pid_file = &quot;#{RAILS_HOME}/tmp/pids/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}.pid&quot;
+PID_FILE = &quot;#{RAILS_HOME}/tmp/pids/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}.pid&quot;
 SERVER_LOGGER = &quot;#{RAILS_HOME}/log/backgroundrb_debug_#{BDRB_CONFIG[:backgroundrb][:port]}.log&quot;
 
-case ARGV[0]
-when 'start'
-  if fork
-    sleep(5)
-    exit
-  else
-    op = File.open(pid_file, &quot;w&quot;)
-    op.write(Process.pid().to_s)
-    op.close
-    if BDRB_CONFIG[:backgroundrb][:log].nil? or BDRB_CONFIG[:backgroundrb][:log] != 'foreground'
-      log_file = File.open(SERVER_LOGGER,&quot;w+&quot;)
-      [STDIN, STDOUT, STDERR].each {|desc| desc.reopen(log_file)}
-    end
+daemon = BackgrounDRb::StartStop.new
 
-    BackgrounDRb::MasterProxy.new()
-  end
-when 'stop'
-  def kill_process arg_pid_file
-    pid = nil
-    File.open(arg_pid_file, &quot;r&quot;) { |pid_handle| pid = pid_handle.gets.strip.chomp.to_i }
-    begin
-      pgid =  Process.getpgid(pid)
-      Process.kill('TERM', pid)
-      Process.kill('-TERM', pgid)
-      Process.kill('KILL', pid)
-    rescue Errno::ESRCH =&gt; e
-      puts &quot;Deleting pid file&quot;
-    rescue
-      puts $!
-    ensure
-      File.delete(arg_pid_file) if File.exists?(arg_pid_file)
-    end
-  end
-  pid_files = Dir[&quot;#{RAILS_HOME}/tmp/pids/backgroundrb_*.pid&quot;]
-  pid_files.each { |x| kill_process(x) }
-else
-  BackgrounDRb::MasterProxy.new()
+case ARGV[0]
+when 'start'; daemon.start
+when 'stop'; daemon.stop()
+else; BackgrounDRb::MasterProxy.new()
 end
 </diff>
      <filename>script/backgroundrb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>39036470702813ad3bf3e4a9fef7cbe4d895765e</id>
    </parent>
  </parents>
  <author>
    <name>gnufied</name>
    <email>gethemant@gmail.com</email>
  </author>
  <url>http://github.com/gnufied/backgroundrb/commit/d211e3ec2d868b867c83ef57ea3ef567c1c8c5ac</url>
  <id>d211e3ec2d868b867c83ef57ea3ef567c1c8c5ac</id>
  <committed-date>2008-10-03T14:40:54-07:00</committed-date>
  <authored-date>2008-10-03T14:40:54-07:00</authored-date>
  <message>improve start stop managment</message>
  <tree>ee072b2379e65c4e78b73b5551dc7b4754aabd93</tree>
  <committer>
    <name>gnufied</name>
    <email>gethemant@gmail.com</email>
  </committer>
</commit>
