I installed JRuby 1.7.2 in RVM, created a gemset, executed bundle install. Now, I run this:
Term 1:
[lzap@lzapx my_app]$ bundle exec jruby --ng-serv
NGServer started on all interfaces, port 2113.
Term 2:
[lzap@lzapx my_app]$ JRUBY_OPTS="--1.9 --ng" bundle exec rails s
The issue is nothing happens, on both sides the terminals do not print anything, it just hangs forever. Top does not show any java/jruby processes working.
If I try to start the application without --ng, it works okay. What is the issue? Bundler?
Firewall is disabled of course.
It's possible to generate a binstub for rails …
$ bundle binstubs rails
… and edit it to set the JRUBY_OPTS.
ENV['JRUBY_OPTS'] = '--1.9 --ng --nailgun-port 2113'
load Gem.bin_path('rails', 'rails')
This way only the bundler-wrapped portion of the client is executed in the bundler-wrapped nailgun server.
Since nailgun doesn't propagate signals you might want to use a controller to stop it:
class RailsController < ApplicationController
def stop
Process.kill :INT, 0
end
end
Benchmark:
$ time bin/rails -v # modified
Rails 3.0.11
real 0m3.737s
user 0m6.579s
sys 0m0.223s
$ time bin/rails -v # unmodified
Rails 3.0.11
real 0m5.547s
user 0m12.739s
sys 0m0.411s
$ time bundle exec rails -v
Rails 3.0.11
real 0m9.145s
user 0m20.708s
sys 0m0.682s
A second 'non-bundle-exec'ed server could be used in theory. To avoid explicit restarts but allow killing (with two Ctrl-C presses) I'd suggest this loop:
$ while sleep 1; do jruby --ng-server 2112; done
The port for the second nailgun instance has to be specified in the outside client:
$ JRUBY_OPTS='--1.9 --ng --nailgun-port 2112' bin/rails s
I didn't see a performance improvement and the output appearing in the 'wrong' console is annoying. But maybe this is faster on other systems. And someone else might see a way improve this approach?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With