![](/img/trans.png)
[英]Rails app fails to deploy when upgrading elastic beanstalk stack
[英]Rails app fails to deploy on elastic beanstalk
我有一个使用 ruby 2.3 的 Rails 4 应用程序,我想使用 AWS Ebs 进行部署。 我将数据库连接指向现有数据库,我正在使用 cli 进行初始化和创建。 当我到达创建部分时,我不断收到一条错误消息,内容为:
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
这当然意味着迁移失败。 当我检查日志时,它说表已经存在,我做了一些研究,发现您可以在.ebextensions/
包含设置以指定不在测试和开发上运行迁移或运行包。 这是我的.ebextensions/ruby-settings.config
:
option_settings: BUNDLE_WITHOUT: "test:development" RAILS_ENV: production RACK_ENV: production RAILS_SKIP_MIGRATIONS: true
但是它仍然无法部署并给出相同的错误消息。 问题是,我在这里做错了什么? 我试着重写基础上的教程我在此找到这个配置文件不同的方式博客和AWS文档页面在这里。
关于我做错了什么的任何想法都是有帮助的,因为我目前不知所措。
将您的 ruby-settings.config 更改为以下,然后尝试迁移。
option_settings:
- option_name: BUNDLE_WITHOUT
value: "test:development"
- option_name: RAILS_ENV
value: "production"
- option_name: RACK_ENV
value: "production"
- option_name: RAILS_SKIP_MIGRATIONS
value: "true"
我发现我的问题的答案是我在我的 .gitignore 中添加了 .ebextensions。 在部署过程的早期,.elasticbeanstalk 已被添加为忽略,我认为需要对 .ebextensions 做同样的事情。 一个小小的疏忽导致了很多挫折。
值得注意的是,当我的配置文件中确实存在间距问题时,ebcli 向我抛出了一个错误。 我相信 error2007s 发布的内容是有效的,但是其他格式是可以接受的。 例如,这是我的配置文件之一的当前格式:
option_settings:
aws:ec2:vpc:
VPCId: vpc-xxxxxxxx
Subnets: subnet-yyyyyyy,subnet-zzzzzzzz,subnet-wwwwwww,subnet-eeeeeeeee
aws:autoscaling:launchconfiguration:
SecurityGroups: sg-00000000
等等...
我还建议使用 .ebextensions 来设置您的环境变量,就像我所做的那样:
option_settings:
aws:elasticbeanstalk:application:environment:
RAILS_SKIP_MIGRATIONS: true
RAILS_ENV: production
文件名:0000.config
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02b_set_env_vars.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
cd $EB_APP_STAGING_DIR
./set-env.sh
并且有一些错误,例如 -
进入/opt/elasticbeanstalk/hooks/configdeploy/pre/<>_setup_envvars.sh
复制最后两行 -
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir) $EB_SUPPORT_DIR/export_envvars
并粘贴到 0000.config - 现在文件看起来像 -
文件名:0000.config
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02b_set_env_vars.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
$EB_SUPPORT_DIR/export_envvars
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.