starting ruby code from within jvm

View: New views
3 Messages — Rating Filter:   Alert me  

starting ruby code from within jvm

by jason franklin-stokes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

dear groupies,

this could be a very stupid question - i am hoping at least.

i have written a little application using jruby.

when i do
 > jruby -S myapp.rb

I am assuming that jvm is loaded, then jruby and then myapp.rb

I actually want to start myapp a number of times so it can do its  
stuff in parallel. When I do that it seems that jvm, jruby and  
myapp.rb all get loaded into memory again - which is what i would  
expect.

Question: how would I go about just loading and executing myapp.rb  
multiple times as separate processes which would not involve loading  
jvm jruby each time?

Thanks for any insights?

Jason.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: starting ruby code from within jvm

by Joseph Athman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe something simple like this?

3.times do
  Thread.new do
    load 'myapp.rb'
  end
end

This would load up three separate native threads and run your program. 

On Fri, Oct 30, 2009 at 12:41 PM, jason franklin-stokes <jasoninclass@...> wrote:
dear groupies,

this could be a very stupid question - i am hoping at least.

i have written a little application using jruby.

when i do
> jruby -S myapp.rb

I am assuming that jvm is loaded, then jruby and then myapp.rb

I actually want to start myapp a number of times so it can do its stuff in parallel. When I do that it seems that jvm, jruby and myapp.rb all get loaded into memory again - which is what i would expect.

Question: how would I go about just loading and executing myapp.rb multiple times as separate processes which would not involve loading jvm jruby each time?

Thanks for any insights?

Jason.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email




Re: starting ruby code from within jvm

by Paweł Wielgus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jason,
inside java code You can use jsr233 (java scripting api) or the new
RedBridge implementation. That way You can have one master process in
java that will start threads that will execute your ruby script. One
other way would be to do it with ruby master process run inside jruby
and using eval method to run your script in threads.

Best greetins,
Pawel Wielgus.

2009/10/30, jason franklin-stokes <jasoninclass@...>:

> dear groupies,
>
> this could be a very stupid question - i am hoping at least.
>
> i have written a little application using jruby.
>
> when i do
>  > jruby -S myapp.rb
>
> I am assuming that jvm is loaded, then jruby and then myapp.rb
>
> I actually want to start myapp a number of times so it can do its
> stuff in parallel. When I do that it seems that jvm, jruby and
> myapp.rb all get loaded into memory again - which is what i would
> expect.
>
> Question: how would I go about just loading and executing myapp.rb
> multiple times as separate processes which would not involve loading
> jvm jruby each time?
>
> Thanks for any insights?
>
> Jason.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email