Jorge Dias
2008-Nov-20 10:48 UTC
[Backgroundrb-devel] Stopping bdrb from another process gets the process killed
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>
hemant
2008-Nov-20 11:29 UTC
[Backgroundrb-devel] Stopping bdrb from another process gets the process killed
On Thu, Nov 20, 2008 at 4:18 PM, Jorge Dias <theturingmachine at gmail.com> wrote:> 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/318949Hmm, I will play with this and let you know. Doesn''t look like much of problem, except that system call is opaque.
Seemingly Similar Threads
- Start script not working when run via Rake
- primary GID based access for user in 16 supplementary groups
- Select rows based on matching conditions and logical operators
- trying to resurrect discussion about "Cannot signal a process over a channel (rfc 4254, section 6.9)"
- rsync in cygwin as service