<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/20081005210917_add_scheduled_at_to_bdrb_job_queues.rb</filename>
    </added>
  </added>
  <modified type="array">
    <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>f2ad453b2cee3dcf82e103cc73532260d8d7eda9</id>
    </parent>
  </parents>
  <author>
    <name>Kieran Pilkington</name>
    <email>kieran@katipo.co.nz</email>
  </author>
  <url>http://github.com/kete/kete/commit/09beea18748ac8ac8706e56b196dcaead8202451</url>
  <id>09beea18748ac8ac8706e56b196dcaead8202451</id>
  <committed-date>2008-10-05T14:14:01-07:00</committed-date>
  <authored-date>2008-10-05T14:14:01-07:00</authored-date>
  <message>bugfix: updating files nessesary for starting/stopping backgroundrb, added missing column through migrations</message>
  <tree>d279a86d63f3ee6ad553b239fea1632d8b602804</tree>
  <committer>
    <name>Kieran Pilkington</name>
    <email>kieran@katipo.co.nz</email>
  </committer>
</commit>
