gpt4 book ai didi

node.js - 用于 Node 64 位和环境的 Amazon Elastic Beanstalk .config

转载 作者:搜寻专家 更新时间:2023-11-01 00:08:42 25 4
gpt4 key购买 nike

这是我的 EB 配置文件 .ebextensions/app.config 的摘录:

option_settings:
- option_name: AWS_SECRET_KEY
value: xxxxxxxxxx
- option_name: AWS_ACCESS_KEY_ID
value: xxxxxxxxxx
- option_name: APP_ENV
value: development
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: ProxyServer
value: nginx
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: GzipCompression
value: true
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeVersion
value: 0.8.10
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeCommand
value: npm start

commands:
test_command:
command: echo $APPLICATION_ENV > /home/ec2-user/test.txt
cwd: /home/ec2-user
ignoreErrors: true

然后我做正常的事情:

$ git commit -am "wrote config file"
$ eb init
...
$ eb start
...
would you like to use the most recent commit [y/n]
$ y

然后在部署完成并处于绿色状态后,查看 eb 生成的 .elasticbeansalk/optionsettings.myapp-env 文件,我发现:

[aws:elasticbeanstalk:application:environment]
PARAM1=
PARAM2=
PARAM3=
PARAM4=
PARAM5=

[aws:elasticbeanstalk:container:nodejs]
GzipCompression=false
NodeCommand=
NodeVersion=0.8.24
ProxyServer=nginx

我的环境变量未设置,NodeCommand 指令未设置,NodeVersion 已被忽略。什么给,EB?它怎么能忽略某些指令而不是其他指令呢?对我做错了什么有什么想法吗?


编辑

根据 this post ,保存环境变量的 JSON 保存在这里:

/opt/elasticbeanstalk/deploy/configuration/containerconfiguration

这意味着我可以为变量解析这个字段,但这很令人沮丧,因为它应该由配置文件处理(否则为什么要有一个?)。我的配置文件肯定还有问题,否则 EB 在这方面似乎完全崩溃了......

最佳答案

我也遇到过这个问题。我相信有两种方法可以解决它。

  1. 运行“eb update”,这应该会更新您的环境并有望获取变量。

  2. 创建一个新环境并将您的代码部署到该环境中。一切正常后,将 dns 指向新环境并删除旧环境。

我还在某处(我相信是 aws 论坛)读到,如果您在 elastic beanstalk gui 界面中更新 env,那么这些值将优先于您放入源代码中的任何内容。

关于node.js - 用于 Node 64 位和环境的 Amazon Elastic Beanstalk .config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18227711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com