[Backgroundrb-devel] Start script not working when run via Rake

Olly Lylo list at lylo.co.uk
Thu Jan 3 10:03:49 EST 2008


Hi there
I'm using the latest release (r300) and 'script/backgroundrb start' works
perfectly when executed on the server, but when put inside a Rake task, it
doesn't launch the worker processes.

The Rake task is as follows:


task :start_backgroundrb do
  run "cd #{current_path} && ./script/backgroundrb start"
end


When I run this task, the following files are created in the log directory:

backgroundrb.pid
backgroundrb_debug.log
backgroundrb_server.log


Observations: The process ID found in backgroundrb.pid doesn't exist,
backgroundrb_server.log is zero bytes long and backgroundrb_debug.log
contains the following:

# Logfile created on Thu Jan 03 14:43:24 +0000 2008 by /


It looks like the process is being started by Rake, but terminates before
the worker processes are started.   Could anyone shed any light on why this
might be happening and how I can resolve the issue?

I have also noticed that calling './script/backgroundrb stop' when
BackgroundRB isn't running throws an exception, which causes problems when
executing 'backgroundrb stop' in a rake task.  As a workaround I have
modified by 'backgroundrb' script as follows:

when 'stop'
  path = "#{RAILS_HOME}/log/backgroundrb.pid"
  pid = nil
  begin
    File.open(path, "r") { |pid_handle| pid =
pid_handle.gets.strip.chomp.to_i }
    pgid =  Process.getpgid(pid)
    Process.kill('TERM', pid)
    Process.kill('-TERM', pgid)
    Process.kill('KILL', pid)
  rescue
    puts $!
  ensure
    puts "Deleting pid file"
    File.delete(path) if File.exists?(path)
  end




Cheers, Olly


---
FreeAgent: Streamlined Money Management for UK Freelancers, Contractors and
Consultants
www.freeagentcentral.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080103/5492d04a/attachment.html 


More information about the Backgroundrb-devel mailing list