简体   繁体   English

环境变量访问AWS

[英]Environment variable access AWS

Why can my application not access environment variables that I have set? 为什么我的应用程序无法访问我设置的环境变量? I deployed a WAR to AWS and set environment variables via ssh, but am unable to read them in. This process works in my dev environment, so not sure why it won't work in production. 我向AWS部署了一个WAR并通过ssh设置了环境变量,但我无法读取它们。这个过程适用于我的开发环境,所以不确定为什么它在生产中不起作用。 Any ideas? 有任何想法吗? I am on a windows box locally and a linux box in production, but I don't think that should matter. 我在本地的Windows机箱和生产中的Linux机箱,但我认为这不重要。

The environment variables should be set so that the user your app's process is running as can see them. 应该设置环境变量,以便应用程序的进程正在运行的用户可以看到它们。

You say you are deploying a WAR - so my guess is that it's on tomcat - you could add your environment variables to the setenv.sh script in the tomcat/bin directory. 你说你正在部署一个WAR - 所以我的猜测是它在tomcat上 - 你可以将你的环境变量添加到tomcat / bin目录中的setenv.sh脚本中。

Sample setenv.sh contents with a few options for tomcat and an environment variable: 使用tomcat和环境变量的几个选项对setenv.sh内容进行示例:

export CATALINA_OPTS="-Xmx1024M -XX:PermSize=512M -Duser.timezone=UTC -DgeoIPFile='/some/path/to/GeoIP.dat' -DxafileDir='/tmp/xafile' -DuploadDir='/path/to/uploads/dir'"
export MYENVVAR="12345"

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

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