Question

In my Nginx/Unicorn Opsworks environment i've set our custom JSON rails_env attribute to "opsworks"

{
"deploy": {
    "myapp": {
        "rails_env": "opsworks"
    }
}

But when I go into the Rails console and run Rail.env Rails returns "development". Opsworks is starting Unicorn under the opsworks environment but Rails seems to be running in development. The log directory contains logs for both development and opsworks.

Any thoughts on what i'm doing wrong?

Was it helpful?

Solution

What you are doing is setting up RAILS_ENV for your rails application. You can view the source here : https://github.com/aws/opsworks-cookbooks/blob/master/unicorn/definitions/unicorn_web_app.rb

this does not set the shell / ssh enviornment variable for you when you ssh login.

to do that manually :

sudo su deploy  # change to deploy user
cd /srv/www/application_short_name/current  # drop into the specific directory
RAILS_ENV=opsworks rails c

This will give you the appropriate rails env when you're running the commands.

You can automate this part / make it easier by creating a .bashrc file for your users with the following lines added :

export RAILS_ENV=opsworks
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top