Merge pull request #140 from jc00ke/foreman
--- Fixes #2 This is my first patch for JRuby, so any feedback would be appreciated. The specs do not run (Ill file a separate issue) but I am able to successfully start up & run the contents of a `Procfile`. I based this patch on [launchys JRuby support](https://github.com/copiousfreetime/launchy/pull/10) and I too confirmed these changes did not break 1.8.7, 1.9.2 or 1.9.3.
This commit is contained in:
@@ -2,6 +2,10 @@ source "http://rubygems.org"
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
platform :jruby do
|
||||||
|
gem 'spoon', '~> 0.0.1'
|
||||||
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'parka'
|
gem 'parka'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ GEM
|
|||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
fakefs (0.3.2)
|
fakefs (0.3.2)
|
||||||
hpricot (0.8.2)
|
hpricot (0.8.2)
|
||||||
|
hpricot (0.8.2-java)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
mustache (0.11.2)
|
mustache (0.11.2)
|
||||||
parka (0.6.2)
|
parka (0.6.2)
|
||||||
@@ -25,6 +26,7 @@ GEM
|
|||||||
thor
|
thor
|
||||||
rake (0.9.2.2)
|
rake (0.9.2.2)
|
||||||
rcov (0.9.8)
|
rcov (0.9.8)
|
||||||
|
rcov (0.9.8-java)
|
||||||
rdiscount (1.6.5)
|
rdiscount (1.6.5)
|
||||||
rest-client (1.6.1)
|
rest-client (1.6.1)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
@@ -42,11 +44,13 @@ GEM
|
|||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-mocks (2.8.0)
|
rspec-mocks (2.8.0)
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.4)
|
||||||
|
spoon (0.0.1)
|
||||||
term-ansicolor (1.0.7)
|
term-ansicolor (1.0.7)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
xml-simple (1.0.15)
|
xml-simple (1.0.15)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
|
java
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
@@ -60,3 +64,4 @@ DEPENDENCIES
|
|||||||
rr (~> 1.0.2)
|
rr (~> 1.0.2)
|
||||||
rspec (~> 2.0)
|
rspec (~> 2.0)
|
||||||
rubyzip
|
rubyzip
|
||||||
|
spoon (~> 0.0.1)
|
||||||
|
|||||||
+18
-7
@@ -1,4 +1,6 @@
|
|||||||
require "foreman"
|
require "foreman"
|
||||||
|
require "rubygems"
|
||||||
|
require "spoon" if RUBY_PLATFORM == "java"
|
||||||
|
|
||||||
class Foreman::Process
|
class Foreman::Process
|
||||||
|
|
||||||
@@ -27,15 +29,24 @@ class Foreman::Process
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def jruby?
|
||||||
|
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
|
||||||
|
end
|
||||||
|
|
||||||
def fork_with_io(command)
|
def fork_with_io(command)
|
||||||
reader, writer = IO.pipe
|
reader, writer = IO.pipe
|
||||||
pid = fork do
|
command = replace_command_env(command)
|
||||||
trap("INT", "IGNORE")
|
pid = if jruby?
|
||||||
writer.sync = true
|
Spoon.spawnp Foreman.runner, command
|
||||||
$stdout.reopen writer
|
else
|
||||||
$stderr.reopen writer
|
fork do
|
||||||
reader.close
|
trap("INT", "IGNORE")
|
||||||
exec Foreman.runner, replace_command_env(command)
|
writer.sync = true
|
||||||
|
$stdout.reopen writer
|
||||||
|
$stderr.reopen writer
|
||||||
|
reader.close
|
||||||
|
exec Foreman.runner, command
|
||||||
|
end
|
||||||
end
|
end
|
||||||
[ reader, pid ]
|
[ reader, pid ]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user