简体   繁体   English

Capistrano未设置环境变量AWS EC2

[英]Capistrano not setting env vars AWS EC2

I currently have an app deployed with capistrano in an EC2 instance in AWS. 我目前在AWS的EC2实例中使用capistrano部署了一个应用程序。

For some reason, some of the ENV VARS are not set when the app runs. 由于某些原因,应用运行时未设置某些ENV VARS。 If I connect via SSH and do a printenv or use the rails console, the ENV VARs do show properly. 如果我通过SSH连接并执行printenv或使用rails控制台,则ENV VAR会正确显示。 But for the running app, the ENV VARs do not show. 但是对于正在运行的应用程序,不会显示ENV VAR。

I've got little experience with Capistrano and EC2 so I'm not entirely sure what code should I share and I don't know where to check if my configuration is properly done. 我对Capistrano和EC2的经验很少,所以我不确定应该共享什么代码,也不知道在哪里检查我的配置是否正确完成。

How do I set up the environment variables so that they are accesible for the deployed application? 如何设置环境变量,以使它们可用于已部署的应用程序?

You can set the environment variables for capistrano session: 您可以为capistrano会话设置环境变量:

set :default_environment, { 
 'environment_variable_1' => 'value_1',
 'environment_variable_2' => 'value_2'
}

I've found my answer here: Capistrano and API keys in ENV variables? 我在这里找到了答案: ENV变量中的Capistrano和API密钥?

I had to follow any of the methods described there to set the env vars. 我必须遵循那里描述的任何方法来设置环境变量。 I've actually followed the second method, using the dotenv gem. 实际上,我使用了dotenv gem来遵循第二种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM