Reputation: 143
I cannot for the life of me figure out how to get OpsWorks to use my rails staging environment. I have development, staging and production. Development for local machine and staging and production for two different stacks on OpsWoks. I am just trying to get my staging environment working, but it keeps deploying as production. Staging is basically a duplication of my development environment, but it's able to send email externally and has a different database host instead of localhost.
I am setting this custom json so far in my stack settings:
{
"deploy": {
"my_app_name": {
"rails_env": "staging",
"database": {
"adapter": "mysql2"
}
}
}
}
I kept having database connection issues with RDS until I added this database adapter key/pair. I just can't get it to start my rails app in staging.
When creating the App and specifying the git source and RDS it asks for "Rails environment". I set this to staging thinking that is all I needed to do to define what rails environment to use.
Any experts with OpsWorks that can help, it is greatly appreciated. I just started setting this up today. I wish the docs had a little better examples.
Upvotes: 2
Views: 479
Reputation: 20106
OpsWorks will start the app with the rails_env you specify in the custom json for the application. A caveat is that if you shell in to the server and do a rails console
, you will see Rails.env
is not equal to what you set in the JSON. This is because OpsWorks starts the application with the setting you entered, but it doesn't save that setting as an environment variable. So when you are on the cli, it doesn't know which environment to use.
For more information, refer to this excellent answer: https://stackoverflow.com/a/21949946/973810
Upvotes: 1