Compare commits

...
4 Commits
Author SHA1 Message Date
David Dollar 9849f4558a 0.49.0 2012-07-11 15:05:47 -04:00
David Dollar 4b53b42be1 1.8 compatibility 2012-07-11 15:05:28 -04:00
David Dollar 219acaf690 use one pgroup for all of foreman and kill that since ruby 1.8 sucks at pgroups 2012-07-11 15:05:20 -04:00
David Dollar f8118d7b40 better debugging 2012-07-11 15:04:30 -04:00
6 changed files with 23 additions and 16 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
foreman (0.48.0) foreman (0.49.0)
thor (>= 0.13.6) thor (>= 0.13.6)
GEM GEM
@@ -39,7 +39,7 @@ GEM
multi_json (~> 1.0.3) multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3) simplecov-html (~> 0.5.3)
simplecov-html (0.5.3) simplecov-html (0.5.3)
thor (0.15.3) thor (0.15.4)
timecop (0.3.5) timecop (0.3.5)
win32console (1.3.0-x86-mingw32) win32console (1.3.0-x86-mingw32)
xml-simple (1.0.15) xml-simple (1.0.15)
+1 -1
View File
@@ -9,6 +9,6 @@ sigterm() {
#trap sigterm SIGTERM #trap sigterm SIGTERM
while true; do while true; do
echo "$NAME: ping" echo "$NAME: ping $$"
sleep 1 sleep 1
done done
+4
View File
@@ -12,6 +12,10 @@ module Foreman
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java" defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
end end
def self.ruby_18?
defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
end
def self.windows? def self.windows?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/ defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
end end
+2 -8
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
@@ -266,7 +260,7 @@ private
loop do loop do
(IO.select(@readers.values).first || []).each do |reader| (IO.select(@readers.values).first || []).each do |reader|
data = reader.gets data = reader.gets
output_with_mutex name_for(@readers.key(reader)), data output_with_mutex name_for(@readers.invert[reader]), data
end end
end end
rescue Exception => ex rescue Exception => ex
+13 -4
View File
@@ -36,16 +36,25 @@ 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
elsif Foreman.ruby_18?
Dir.chdir(cwd) do
fork do
$stdout.reopen output
$stderr.reopen output
env.each { |k,v| ENV[k] = v }
exec command
end
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 +64,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
+1 -1
View File
@@ -1,5 +1,5 @@
module Foreman module Foreman
VERSION = "0.48.0" VERSION = "0.49.0"
end end