opsworks rails.env does not match custom json rails_env

匿名 (未验证) 提交于 2019-12-03 09:18:39

问题:

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?

回答1:

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!