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
+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