简体   繁体   English

将JRuby和MRI用于通用应用

[英]Using JRuby and MRI for a common app

I need to use both JRuby and MRI for my rails app. 我需要在Rails应用程序中同时使用JRuby和MRI。

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. 我在MRI上运行时遇到性能问题。 The background server is started with a rake task and needs to use the Rails environment. 后台服务器以rake任务启动,需要使用Rails环境。

I'm using Passenger for the Web Server. 我正在将Passenger用于Web服务器。 Since JRuby support for Passenger is quite recent, I would like to go with using MRI. 由于JRuby对Passenger的支持是最近的,所以我想使用MRI。

Here's something I want - 这是我想要的-

This uses Ruby 1.9 to start the server : 这使用Ruby 1.9启动服务器:

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. 问题是,第二个命令jruby -S rake要求重新捆绑应用程序。

Is there any way I can get this in place? 我有什么办法可以做到这一点?

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. 在SOA体系结构中,您将向后台服务器发送一条消息,以便它处理作业。

So, in heroku you'd create one application for your web running in MRI; 因此,在heroku中,您将为MRI中运行的Web创建一个应用程序; then you'd create an application in JRuby for your background processes. 然后您将在JRuby中为后台进程创建一个应用程序。 They'd communicate via a shared Redis or shared database. 他们将通过共享的Redis或共享的数据库进行通信。

I would recommend using Trinidad or Puma and keeping it all in JRuby though (as opposed to keep running passenger); 我建议使用特立尼达(Trinidad)或彪马(Puma),并将其全部保留在JRuby中(而不是让乘客忙碌); it'll be a much simpler architecture. 这将是一个简单得多的架构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM