Setting RAILS_ENV from a jvm option?

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

Setting RAILS_ENV from a jvm option?

by technologyrocks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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!
M@


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

Re: Setting RAILS_ENV from a jvm option?

by Tyler Jennings :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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, M@ Hunter <technologyrocks@...> wrote:

>
> 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!
> M@
>
>
> --
> "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