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

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.48.0)
foreman (0.49.0)
thor (>= 0.13.6)
GEM
@@ -39,7 +39,7 @@ GEM
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
thor (0.15.3)
thor (0.15.4)
timecop (0.3.5)
win32console (1.3.0-x86-mingw32)
xml-simple (1.0.15)

View File

@@ -9,6 +9,6 @@ sigterm() {
#trap sigterm SIGTERM
while true; do
echo "$NAME: ping"
echo "$NAME: ping $$"
sleep 1
done

View File

@@ -12,6 +12,10 @@ module Foreman
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
end
def self.ruby_18?
defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
end
def self.windows?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
end

View File

@@ -99,13 +99,7 @@ class Foreman::Engine
# @param [String] signal The signal to send to each process
#
def killall(signal="SIGTERM")
@running.each do |pid, (process, index)|
system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
begin
Process.kill(signal, -1 * pid)
rescue Errno::ESRCH, Errno::EPERM
end
end
Process.kill "-#{signal}", Process.pid
end
# Get the process formation
@@ -266,7 +260,7 @@ private
loop do
(IO.select(@readers.values).first || []).each do |reader|
data = reader.gets
output_with_mutex name_for(@readers.key(reader)), data
output_with_mutex name_for(@readers.invert[reader]), data
end
end
rescue Exception => ex

View File

@@ -36,16 +36,25 @@ class Foreman::Process
if Foreman.windows?
Dir.chdir(cwd) do
Process.spawn env, command, :out => output, :err => output, :new_pgroup => true
Process.spawn env, command, :out => output, :err => output
end
elsif Foreman.jruby?
Dir.chdir(cwd) do
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
else
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
@@ -55,7 +64,7 @@ class Foreman::Process
# @param [String] signal The signal to send
#
def kill(signal)
pid && Process.kill(signal, -1 * pid)
pid && Process.kill("-#{signal}", pid)
rescue Errno::ESRCH
false
end

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.48.0"
VERSION = "0.49.0"
end