Using spoon for JRuby support

This commit is contained in:
jc00ke
2012-01-22 12:27:25 -08:00
parent a008886bd0
commit b4cab08327
3 changed files with 24 additions and 7 deletions
+5
View File
@@ -2,6 +2,7 @@ PATH
remote: .
specs:
foreman (0.36.1)
spoon (~> 0.0.1)
term-ansicolor (~> 1.0.7)
thor (>= 0.13.6)
@@ -17,6 +18,7 @@ GEM
diff-lcs (1.1.3)
fakefs (0.3.2)
hpricot (0.8.2)
hpricot (0.8.2-java)
mime-types (1.16)
mustache (0.11.2)
parka (0.6.2)
@@ -25,6 +27,7 @@ GEM
thor
rake (0.9.2.2)
rcov (0.9.8)
rcov (0.9.8-java)
rdiscount (1.6.5)
rest-client (1.6.1)
mime-types (>= 1.16)
@@ -42,11 +45,13 @@ GEM
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
rubyzip (0.9.4)
spoon (0.0.1)
term-ansicolor (1.0.7)
thor (0.14.6)
xml-simple (1.0.15)
PLATFORMS
java
ruby
DEPENDENCIES
+1
View File
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
gem.add_dependency 'term-ansicolor', '~> 1.0.7'
gem.add_dependency 'thor', '>= 0.13.6'
gem.add_dependency 'spoon', '~> 0.0.1'
end
+18 -7
View File
@@ -1,4 +1,6 @@
require "foreman"
require "rubygems"
require "spoon" if RUBY_PLATFORM == "java"
class Foreman::Process
@@ -27,15 +29,24 @@ class Foreman::Process
private
def jruby?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
end
def fork_with_io(command)
reader, writer = IO.pipe
pid = fork do
trap("INT", "IGNORE")
writer.sync = true
$stdout.reopen writer
$stderr.reopen writer
reader.close
exec Foreman.runner, replace_command_env(command)
command = replace_command_env(command)
pid = if jruby?
Spoon.spawnp Foreman.runner, command
else
fork do
trap("INT", "IGNORE")
writer.sync = true
$stdout.reopen writer
$stderr.reopen writer
reader.close
exec Foreman.runner, command
end
end
[ reader, pid ]
end