use one pgroup for all of foreman and kill that since ruby 1.8 sucks at pgroups

This commit is contained in:
David Dollar committed 2012-07-11 15:05:20 -04:00
1 parent f8118d7b40
commit 219acaf690
2 files changed
+5 -11

No files matched your search

+1 -7
View File
@@ -99,13 +99,7 @@ class Foreman::Engine
# @param [String] signal The signal to send to each process # @param [String] signal The signal to send to each process
# #
def killall(signal="SIGTERM") def killall(signal="SIGTERM")
@running.each do |pid, (process, index)| Process.kill "-#{signal}", Process.pid
system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
begin
Process.kill(signal, -1 * pid)
rescue Errno::ESRCH, Errno::EPERM
end
end
end end
# Get the process formation # Get the process formation
+4 -4
View File
@@ -36,16 +36,16 @@ class Foreman::Process
if Foreman.windows? if Foreman.windows?
Dir.chdir(cwd) do Dir.chdir(cwd) do
Process.spawn env, command, :out => output, :err => output, :new_pgroup => true Process.spawn env, command, :out => output, :err => output
end end
elsif Foreman.jruby? elsif Foreman.jruby?
Dir.chdir(cwd) do Dir.chdir(cwd) do
require "posix/spawn" require "posix/spawn"
POSIX::Spawn.spawn env, command, :out => output, :err => output, :pgroup => 0 POSIX::Spawn.spawn env, command, :out => output, :err => output
end end
else else
Dir.chdir(cwd) do Dir.chdir(cwd) do
Process.spawn env, command, :out => output, :err => output, :pgroup => 0 Process.spawn env, command, :out => output, :err => output
end end
end end
end end
@@ -55,7 +55,7 @@ class Foreman::Process
# @param [String] signal The signal to send # @param [String] signal The signal to send
# #
def kill(signal) def kill(signal)
pid && Process.kill(signal, -1 * pid) pid && Process.kill("-#{signal}", pid)
rescue Errno::ESRCH rescue Errno::ESRCH
false false
end end