Need to get the environment name

Hi All,

I want to get the environment name in which the application is executing whether in production or in development etc using the bash script and want to write that result into the .sh file. Not by using the ruby. Any ideas of how to get this work?

Do you mean the environment on a “bash” level ?

Well, when passenger is used, you could check the RAILS_ENV value

Maybe this is useful ?

http://www.modrails.com/documentation/Users%20guide%20Nginx.html#RailsEnv

HTH,

Peter

Hi All,

I want to get the environment name in which the application is executing
whether in production or in development etc using the bash script and want
to write that result into the .sh file. Not by using the ruby. Any ideas of
how to get this work?

Do you mean you have a rails server running, and from a separate bash
script want to know whether the rails server is running in production
or development or whatever, without doing anything special in the
rails app? Tricky I think.

Rafi
In Every moment, thank God.

Generally I think you are more likely to get help if you do not
attempt to force religious ideas on people.

Colin

You could use the rails runner and do something like

# add rails bin dir to path first!
RAILS_ENV=`rails runner "puts Rails.env"`

That said, if this is something you need access to regularly, add
initializer code to your app to write the end out to a well know file
name under the project that scripts can read without the overhead of
spinning up the app to get that info, scraping logs, etc

Max