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?


Cheers,
Rafi
In Every moment, thank God.

On Mon, Feb 13, 2012 at 1:39 PM, Rafi A [email protected] wrote:

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


*** Available for a new project ***

Peter V.
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v

On 13 February 2012 12:39, Rafi A [email protected] wrote:

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

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