Apoorv Parijat
Apoorv Parijat

Reputation: 871

Using JRuby and MRI for a common app

I need to use both JRuby and MRI for my rails app.

Here's the scenario -

My app uses a background server which handles a lot of threads. I'm having performance issue with running it on MRI. The background server is started with a rake task and needs to use the Rails environment.

I'm using Passenger for the Web Server. Since JRuby support for Passenger is quite recent, I would like to go with using MRI.

Here's something I want -

This uses Ruby 1.9 to start the server :

sudo passenger start -p 80 -e production --user=deploy

and within the same app, this runs the background server -

jruby -S rake background_server:start_daemon RAILS_ENV=production

The problem is, the second command jruby -S rake asks for rebundling the app.

Is there any way I can get this in place?

Upvotes: 0

Views: 159

Answers (1)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

Not in the same app. you'll need separate applications that run under different rubies if you want this to happen. in SOA architecture, you'd send a message to your background server for it to process a job.

So, in heroku you'd create one application for your web running in MRI; then you'd create an application in JRuby for your background processes. They'd communicate via a shared Redis or shared database.

I would recommend using Trinidad or Puma and keeping it all in JRuby though (as opposed to keep running passenger); it'll be a much simpler architecture.

Upvotes: 1

Related Questions