[Backgroundrb-devel] Stopping bdrb from another process gets the process killed

Jorge Dias theturingmachine at gmail.com
Thu Nov 20 05:48:09 EST 2008


Hi, I've been having some issues integrating bdrb on a cruisecontrolrb
server
It's related to the way we stop the bdrb server. The thing is, right now
when we stop the process we are killing the parent of the group of the
process. This is ok if you're running script/backgroundrb stop directly from
the console, but if I'm running this from another process, let's say a rake
task, the rake task gets killed because it gets the SIGTERM signal.

In the class StarStop we have:

  def kill_process arg_pid_file
    pid = nil
    pid = File.open(arg_pid_file, "r") { |pid_handle|
pid_handle.gets.strip.chomp.to_i }
    pgid =  Process.getpgid(pid)
    puts "Stopping BackgrounDRb with pid #{pid}...."
    Process.kill('-TERM', pgid)
    File.delete(arg_pid_file) if File.exists?(arg_pid_file)
    puts "Success!"
  end

What I did was, that instead of killing pgid, I'm doing a system call and
killing the pid, like this

  def kill_process arg_pid_file
    pid = nil
    pid = File.open(arg_pid_file, "r") { |pid_handle|
pid_handle.gets.strip.chomp.to_i }
    puts "Stopping BackgrounDRb with pid #{pid}...."
    system("kill -s TERM #{pid}") #This is what's different
    File.delete(arg_pid_file) if File.exists?(arg_pid_file)
    puts "Success!"
  end

I did the system call because Process, says that there's no process with the
pid we extract from the file.

It's working good, but I don't know if there are some hidden side effects?
any ideas?

here's a rake task so you can try what I'm saying http://pastie.org/318949
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20081120/cc8da325/attachment.html>


More information about the Backgroundrb-devel mailing list