Setting RAILS_ENV from a jvm option?

I realize this is a Rails specific question - but it’s also specific to
jRuby, so I’m hoping someone can help me out as I haven’t found an
answer
via google yet.

We run development, staging, preview and production servers for our java
apps. We use a jvm option on each of these servers to indicate which it
is

  • very much like RAILS_ENV is used - so that java apps can be configured
    to
    act appropriately.

Not only would it be extremely helpful to be able to take advantage of
these
already set JVM options, but I’m stuck if I’m not able to… our
environment is setup such that once a .war file hits staging, that same,
unmodified version is the one that gets pushed up the ladder till it
hits
prod. I can’t, therefore, re-package it with Warbler at each step -
changing the rails_env as we go. (Which is not something I’d consider a
good practice anyway…).

So… can someone shed some light on whether or not I can add something
to
the project to set RAILS_ENV from a jvm option when the app starts up?

Thanks!
[email protected]

We did this by overriding the RAILS_ENV based on an option set in the
jvm. I’m interested if there’s a better way. Looks like this:

JAVA_OPTS="-Drails.env=staging"

in environment.rb

ENV[‘RAILS_ENV’] = ENV_JAVA[‘rails.env’]

-Tyler

On Fri, Oct 23, 2009 at 1:42 PM, [email protected] Hunter [email protected]
wrote:

Not only would it be extremely helpful to be able to take advantage of these
Thanks!
[email protected]


“You can never run a hill too hard. You will give up long before you hurt
the hill…” -Anon


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs