Re: [jruby-user] Anything wrong with shelling out to jruby?

John Joseph Bachir <[email protected]> Tue, 17 Mar 2015 13:15:05 -0400
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CAOf2Z5vcSf7+sqAv9ja31TXKrdB4QYhZWrAtLX2QQT=XtREPbg@mail.gmail.com>
On Tue, Mar 17, 2015 at 9:07 AM, Keith Bennett <[email protected]>
 wrote:

> Is speed not important in your case?
>

It's not important. These are batch jobs that run nightly. This master
script runs a few sub scripts, each of which do a few calculations and then
queue up many (more efficient and well-structured) jobs in my background
job system (sidekiq). Eventually I'd like to make the work in the sub
scripts be done in workers as well, but for the time being I'd like to just
keep things as-is and bring all the invocations into one place, and then
start refactoring.


If I were you, I’d look at minimum to shelling out once rather than a dozen
> times.  Why do you want to shell out so many times?
>

As described above, I have many sub scripts which work and I don't want to
refactor them in this first phase.



> Also, your script looks like it shells out only once, no?
>

That's an example of the code that I'll be doing about a dozen times in the
script.



On Tue, Mar 17, 2015 at 9:10 AM, Ted Han <[email protected]> wrote:

> There's a section about this in the jruby wiki:
> https://github.com/jruby/jruby/wiki/Improving-startup-time#running-sub-rubies-in-the-same-jvm
>

“we will attempt to run it in the same JVM using a new JRuby instance”

Great news, thanks! FYI if others are interested, this feature can be set
at the commandline[1]:

    JRUBY_OPTS="-J-Djruby.launch.inproc=true" rails runner scripts/foo.rb

Or within your ruby code[2]:

    # scripts/foo.rb
    require 'jruby'
    JRuby.runtime.instance_config.run_ruby_in_process = true


[1]
http://developers.mobilesystem7.com/blog/post/speeding-up-rails-on-virtualbox/
[2]
https://github.com/jruby/jruby/wiki/FAQs#how-can-i-increase-the-heapmemory-size-when-launching-a-sub-jruby