Question

I need to run my application on JRuby in production to run native threads to improve the processing power of my application.

However, when developing, I would prefer not to pay the startup costs of the VM since I don't need the extra processing power to develop the application.

Per Heroku's instructions I am using the ruby '1.9.3', engine: 'jruby', engine_version: '1.7.1' directive in my Gemfile to alert them I am planning on using JRuby.

Is there a way that I could instruct bundler to only use JRuby when I am running the app in the staging or production environments and otherwise to just run MRI?

Something like:

IF I AM IN PRODUCTION OR STAGING
  ruby '1.9.3', engine: 'jruby', engine_version: '1.7.1'
ELSE
  ruby '2.0.0', patch_level: 353
END
Was it helpful?

Solution

You can add an environment variable of your choosing to your local server, as well as your staging and production server, and check its value to use the appropriate ruby version, like this:

## based on an ENV variable
if ENV['KIND_OF_SERVER'] == "development"
  ruby '2.0.0', patch_level: 353
else
  ruby '1.9.3', engine: 'jruby', engine_version: '1.7.1'
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top