简体   繁体   English

弹性beanstalk配置错误

[英]elastic beanstalk configuration error

I am trying to launch an app on elastic beanstalk in the php 5.5 container. 我试图在php 5.5容器中的弹性beanstalk上启动一个应用程序。 there are 3 environments dev, staging and production. 有3个环境开发,分期和生产。 You cannot distinguish between environments when setting environment variables from the command line so I am using a workaround suggested by aws support which is to run a shell script on deployment to set the variables depending on the existence of another variable I can vary depending on environment 从命令行设置环境变量时无法区分环境,因此我使用aws支持建议的解决方法,即在部署时运行shell脚本以根据另一个变量的存在来设置变量我可以根据环境而变化

.When i deploy my app there is a config file in .ebextensions/ like so 当我部署我的应用程序时,有一个.ebextensions /中的配置文件

container_commands:
  command01:
    command: "./.ebextensions/setEnvVars.sh"

the shell script is also in .ebextensions and it looks like so shell脚本也在.ebextensions中,它看起来像这样

#!/bin/bash
case "$PARAM1" in
        "development")
                echo -e "SetEnv APP_ENV development\n
                         SetEnv DB_HOST *******\n
                         SetEnv DB_NAME *******\n
                         SetEnv DB_USERNAME *******\n
                         SetEnv DB_PASSWORD *******\n" > .htaccess
                ;;
        "production")
                echo -e "SetEnv APP_ENV production\n
                         SetEnv DB_HOST *******\n
                         SetEnv DB_NAME *******\n
                         SetEnv DB_USERNAME *******\n
                         SetEnv DB_PASSWORD *******\n" > .htaccess
                ;;
        "staging")
                echo -e "SetEnv APP_ENV staging\n
                         SetEnv DB_HOST *******\n
                         SetEnv DB_NAME *******\n
                         SetEnv DB_USERNAME *******\n
                         SetEnv DB_PASSWORD *******\n" > .htaccess
                ;;
esac

if [ -f .htaccess ]; then
        chmod 644 .htaccess
fi

when the app deploys I get this error 当应用程序部署时,我收到此错误

[Instance: i-400fc60f Module: AWSEBAutoScalingGroup ConfigSet: null] Command failed on instance. Return code: 1 Output: Error occurred during build: Command command01 failed .

and this is what I think is the relevant ecert from the logs 这就是我认为日志中的相关ecert

2014-02-03 12:54:25,531 [INFO] (1923 MainThread) [command.py-130] [root command execute] Command returned: (code: 1, stdout: Error occurred during build: Command command01 failed
, stderr: None)
2014-02-03 12:54:25,533 [DEBUG] (1923 MainThread) [commandWrapper.py-60] [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': [{'status': 'FAILURE', 'config_sets': ['Infra-WriteRuntimeConfig', 'Infra-WriteApplication1', 'Infra-WriteApplication2', 'Infra-EmbeddedPreBuild', 'Hook-PreAppDeploy', 'Infra-EmbeddedPostBuild', 'Hook-EnactAppDeploy', 'Hook-PostAppDeploy'], 'returncode': 1, 'events': [], 'msg': 'Error occurred during build: Command command01 failed\n'}], 'api_version': '1.0'}

I don't have any experience with elastic beanstalk or shell so there could easily be a syntax error but I honestly dont know were to look 我没有任何弹性beanstalk或shell的经验,所以很容易出现语法错误,但老实说我不知道​​要看看

Ah, but this is why working with .ebextentions is such great fun! 啊,但这就是为什么使用.ebextentions非常有趣!

From the log you appended, the only thing I'm able to see is that it's in fact your command named command01 that failed. 从你附加的日志中,我唯一能看到的是它实际上是你的命令command01失败了。 Exactly what went wrong is typically an enigma of trial-and-error. 究竟出了什么问题通常是反复试验的一个谜。

This is exactly the place to bring back any old skills you may have in "printf()-debugging". 这正是在“printf() - debugging”中恢复你可能拥有的任何旧技能的地方。 Anything you echo from the scripts you call will also be output into the same log file ( /var/log/cfn-init.log ), allowing you to grok what's going on... 您从调用的脚本中回显的任何内容也将输出到同一个日志文件( /var/log/cfn-init.log )中,这样您就可以了解正在发生的事情......

Looking at your scripts, however, my guess would be that $PARAM1 is undefined. 但是,看看你的脚本,我的猜测是$ PARAM1未定义。 Try passing it as a parameter to your shell script in your container_command like so: 尝试将它作为参数传递给container_command shell脚本,如下所示:

container_commands:
    command01:
        command: "./.ebextensions/setEnvVars.sh" ${PARAM1}

And then use the first argument in your Bash case statement: 然后使用Bash case语句中的第一个参数:

#!/bin/bash
case "$1" in
    ...
esac

Good luck! 祝好运!


Edit: Oh, one more thing. 编辑:哦,还有一件事。 You'll of course need to set the PARAM1 parameter in your AWS Console. 您当然需要在AWS控制台中设置PARAM1参数。 You do this in Configuration > Software Configuration > Environment Properties . 您可以在Configuration > Software Configuration > Environment Properties执行此Configuration Just in case you haven't done this already... 万一你还没有这样做......

A useful trick for debugging issues with scripts is to redirect stdout/stderr to a file. 调试脚本问题的一个有用技巧是将stdout / stderr重定向到文件。

commands:
  command-00:
    command: my_command args >> commands.out 2&>1

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

相关问题 AWS Elastic Beanstalk + Laravel、Nginx配置 - AWS Elastic Beanstalk + Laravel, Nginx Configuration 将 Laravel 应用程序部署到 AWS Elastic Beanstalk 时出错 - Error Deploying Laravel App to AWS Elastic Beanstalk Elastic Beanstalk实例上的WkHtmlToPDF libjpeg错误 - WkHtmlToPDF libjpeg error on Elastic Beanstalk Instance Elastic Beanstalk - 自定义 Nginx 配置文件 - PHP Web 应用程序 - Elastic Beanstalk - Customize Nginx configuration files - PHP Web Application AWS Elastic Beanstalk 在 nginx 服务器上应用配置文件 - AWS Elastic Beanstalk Apply configuration file on nginx server imagerotate上的弹性beanstalk linux php GD库错误 - elastic beanstalk linux php GD library error on imagerotate 与RDS建立数据库连接错误AWS Elastic Beanstalk - Error Establishing Database Connection AWS Elastic Beanstalk with RDS 条带支付后 AWS Elastic Beanstalk 内部服务器错误 - AWS Elastic Beanstalk internal server error after stripe payment AWS 错误 404 Not Found nginx/1.18.0 in elastic beanstalk with laravel - AWS error 404 Not Found nginx/1.18.0 in elastic beanstalk with laravel Laravel 部署在 CodePipeline 中的 Elastic Beanstalk 应用程序给出 500 SERVER ERROR - Laravel Elastic Beanstalk app deployed in CodePipeline giving 500 SERVER ERROR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM