In it I mention some problems specifying certain options on the command
line or in the JRUBY_OPTS environment variable, and some Jira issues
about that.
I would greatly appreciate any feedback, including corrections, which I
would incorporate into the article.
If you’re running on a Unix variant (Mac OS, Linux), try including
“–ng” in the value of the environment variable JRUBY_OPTS. One way to
do this would be on the command line itself:
JRUBY_OPTS=–ng rails …
You’d need to add any additional stuff to JRUBY_OPTS that you were
already using, so you could do:
JRUBY_OPTS=“–ng --1.9” rails …
There are other ways too, such as:
export JRUBY_OPTS=“$JRUBY_OPTS --ng”
rails …
Did you try the strategy suggested in the article and have a problem?
What have you tried, and what happened? What OS are you using? What
version of JRuby?
Did you try the strategy suggested in the article and have a problem? What
have you tried, and what happened? What OS are you using? What version of
JRuby?
I’m using linux debian.
jruby -v
jruby 1.6.8 (ruby-1.9.2-p312) (2012-09-18 1772b40) (OpenJDK 64-Bit
Server VM 1.6.0_24) [linux-amd64-java]
I’ve run jruby --ng-server and the server starts.
First to set bash profiles I’ve tried to run from command line.
rails s starts but it seems not to use nailgun.
jruby --ng rails s says:
ng executable not found.
How to run rails s from command line to use nailgun?
Rails is an executable command, like rake and rspec, that itself
starts up jruby.
Thus, there is no need to specify jruby on the rails command line.
When calling jruby itself, you can specify an option on the command
line, or in the JRUBY_OPTS environment variable.
When calling a JRuby executable like rails, I doubt that the command
line approach will work, so we need to use the JRUBY_OPTS approach.
Try issuing this command on your command line:
JRUBY_OPTS=–ng rails -v
My article explained how to easily set up some scripts that would make
this even more painless. If you have the time to explore that, it
would simplify this for you.
I’ve had exactly the same result as MSAN when I tried jruby --ng
myprog.rb
Without Nailgun jruby myprog.rb works perfectly. (Xubuntu 12.04)
Perhaps someone could explain what adding --ng to JRUBY_OPTS does.
Normally I don’t do anything with that variable and ‘echo $JRUBY_OPTS’
returns a blank line.
Does it matter to Nailgun where the JRuby interpreter is located?
On Sat, Sep 22, 2012 at 2:26 PM, Robin McKay [email protected]
wrote:
I’ve had exactly the same result as MSAN when I tried jruby --ng
myprog.rb
You said that you had exactly the same result as Mauro, but I don’t
see the similarity in what you and he were trying to do, since he was
running an executable that itself calls jruby, and you’re running a
Ruby script.
Could you post here the exact command you’re using, and the resulting
output?
Without Nailgun jruby myprog.rb works perfectly. (Xubuntu 12.04)
Perhaps someone could explain what adding --ng to JRUBY_OPTS does.
Normally I don’t do anything with that variable and ‘echo $JRUBY_OPTS’
returns a blank line.
Please see the reply I just sent to Mauro for more on this. When you
add --ng to JRUBY_OPTS , JRuby sees that you want to run it in a
Nailgun server, and does so. This is pretty amazing, because you can
be running dozens of tasks in a Nailgun server, and only one JVM is
doing it. You can verify this by running jvisualvm (comes with the
JDK), and noting the JVM’s it finds (displayed on the left side)
(anyone know a way to display all running JVM’s on the command line?).
If you run irb without Nailgun, you’ll see a new JVM there; but if
you run irb with Nailgun, you’ll see that no new JVM shows up.
Does it matter to Nailgun where the JRuby interpreter is located?
No. The JRuby installation includes Nailgun, and when you ask JRuby
to use Nailgun, it knows where to find it.
I searched through the JRuby source code, and found this in
bin/jruby.sh:
if [ -f $JRUBY_HOME/tool/nailgun/ng ]; then
exec $JRUBY_HOME/tool/nailgun/ng org.jruby.util.NailMain
$JRUBY_OPTS “$@”
else
echo “error: ng executable not found; run ‘make’ in
${JRUBY_HOME}/tool/nailgun”
exit 1
fi
Could you try running make in the appropriate directory and see if it
succeeds in building ng?
I installed JRuby using rvm, and I think I remember seeing it build
Nailgun as part of the installation. If you’re not using rvm, I’d
highly recommend it, though of course this should not be necessary to
get Nailgun to work. Installation instructions are at RVM: Ruby Version Manager - Installing RVM. After it’s installed, install JRuby with
‘rvm install jruby’.
A brief Google search for “JRuby Nailgun bug” didn’t turn up anything
that looked relevant to your situation, so having to build Nailgun
manually may be the intended behavior, I don’t know.
Robin, when you start the server in a terminal, the server receives any
keyboard input; that input is not being interpreted by the shell. If
you add “&” to the command line when starting the server, the server
will start and go to the background so that the terminal can accept
input normally. You can bring it back to the foreground with the ‘fg’
command. Personally, I leave it alone and don’t use that terminal for
anything else; that makes it easier for me to find when I want to kill
it, since I typically have many shells running.
There is a shell script called configure in my /tools/nailgun directory.
When I did “./configure” it created some files and then I could do
“make” and it worked. After that “jruby --ng test1.rb” worked, and it
does load faster.
Thank you Keith_b for taking the trouble to explore jruby.sh, but it
shouldn’t have been necessary.
This is typical of the poor documentation in open-source software - the
amount of time that users waste trying to figure out this sort of thing
would probably pay for two or three copies of Windows. Heresy, I know,
but probably true.
Also, why couldn’t the Nailgun developers make a product that doesn’t
need these steps?
There is a shell script called configure in my /tools/nailgun directory.
When I did “./configure” it created some files and then I could do
“make” and it worked. After that “jruby --ng test1.rb” worked, and it
does load faster.
This is a standard UNIX dance.
Thank you Keith_b for taking the trouble to explore jruby.sh, but it
shouldn’t have been necessary.
This is typical of the poor documentation in open-source software - the
amount of time that users waste trying to figure out this sort of thing
would probably pay for two or three copies of Windows. Heresy, I know,
not probably true.
A benefit of open-source software is that you contribute, if you feel
that
something could be improved.
There is a shell script called configure in my /tools/nailgun directory.
When I did “./configure” it created some files and then I could do
“make” and it worked. After that “jruby --ng test1.rb” worked, and it
does load faster.
Damn, my wrong.
Of course…I’ve to run configure first.
I have now tried using Nailgun with a “proper” program - a photoviewer I
am developing for my own use that uses Swing to display stuff - and it
doesn’t work properly. Strange things seem to happen to the menus and it
stops with no warning after 6 or 7 navigation button clicks.
I might try Nailgun again in a few years when it is fixed!
I disagree with James A.'s “A benefit of open-source software is that
you contribute … You then get to experience the internal glow …”
If I want to contribute to Open Source software it should be on a
voluntary basis “because I want to” rather than “because I have to”.
I quite understand that people may develop “incomplete” software and
make it available “as is” and it may or may not be useful to me. I hope,
however, that if I did so I would provide enough documentation so that
users could understand the limitations or the product would be small
enough that a user could read through it and figure out what changes
might be needed.
I don’t see Ruby, JRuby or Java in this category. These products are far
too complex for the “ordinary” user to figure out and correct problems.
I don’t see Ruby, JRuby or Java in this category. These products are far
too complex for the “ordinary” user to figure out and correct problems.
Not sure if you are trolling or not but…
Your experiences with ng have nothing to do with ruby or java or even
jruby. Besides none of these things are meant to be used by “ordinary”
users, they are programming languages meant to be used by programmers.
If ng is broke feel free to file a ticket. Without bug reports how are
they going to know what to fix?
I agree with you that this looks like an issue that needs addressing.
However:
We must never forget that open source software is a gift, provided
mostly by people who donate their free time. We are not “entitled” to
anything. We should feel humbled by, and grateful for, their generosity,
and hopefully even be motivated to give of ourselves as well.
We beneficiaries of this are responsible to do our part – in this
case, as was suggested, to file a bug report. This will take a little
time, especially if done right – that is, expressed precisely, clearly,
and with examples, and with a search first to see if the issue has
already been reported. That is one small but helpful thing we can do to
assist the authors. Even better would be to write up the documentation
you wish would have been there, and include a link to it in the bug
report.
Nailgun is a tool, and is not suitable for all purposes. Its strength
is running large numbers of short-lived jobs, and is not really
appropriate in my opinion for a Swing app. Why don’t the JRuby docs say
that? It is a Java tool that was adapted to JRuby by the JRuby
developers. Nailgun has its own home page, at Nailgun: Insanely Fast Java.
Despite the occasional rough edge, JRuby is an awesome product. The
.Net world lost their Ruby implementation (Iron Ruby) a while back. I’m
grateful that we have JRuby for the JVM. The Nailgun integration is not
a strictly necessary part of the JRuby project, but is a very handy
addition. And, using rvm, it works out of the box.