简体   繁体   English

Rails与数据库适配器的弹性beanstalk部署错误

[英]Rails aws elastic beanstalk deploy error with database adapter

I'm trying to deploy my rails application to aws elastic beanstalk, with guidance of this article. 我正在尝试将我的rails应用程序部署到aws弹性beanstalk,在本文的指导下。

https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2#.tnssj8z0o https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2#.tnssj8z0o

Before starting, "Using PostgreSQL with Rails" part, I had no problems. 在开始之前,“使用PostgreSQL和Rails”部分,我没有遇到任何问题。

In that part, I followed the gemfile modifying, which adds the postgreSQL gem to the production group, and moves sqlite3 gem to the development & test group, as I did other rails apps. 在那部分,我遵循gemfile修改,它将postgreSQL gem添加到生产组,并将sqlite3 gem移动到开发和测试组,就像我做其他rails应用程序一样。

Like this 像这样

group :development, :test do
   # Before insert this group, sqlite3 gem code is in the default group. (Outside of development group)
   gem 'sqlite3', '~> 1.3.10' 
   ...other gems...
end
group :production do
   gem 'pg', '~> 0.18.1'
end

After then, I $ bundle install , $ git commit , and $ eb deploy . 之后,I $ bundle install$ git commit$ eb deploy But in this time, EBS makes error with below messages 但是在这个时候,EBS对以下消息犯了错误

ERROR: [Instance: i-80ee5327] Command failed on instance. 错误:[实例:i-80ee5327]命令在实例上失败。 Return code: 1 Output: (TRUNCATED)...sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). 返回码:1输出:(TRUNCATED)... sqlite3'`到您的Gemfile(并确保其版本达到ActiveRecord所需的最小值)。

Gem::LoadError: sqlite3 is not part of the bundle. Gem :: LoadError:sqlite3不是捆绑包的一部分。 Add it to Gemfile. 将其添加到Gemfile。

Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace). 任务:TOP => db:migrate => db:load_config(通过使用--trace运行任务来查看完整跟踪)。

Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. 挂钩/opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh失败。 For more detail, check /var/log/eb-activity.log using console or EB CLI. 有关更多详细信息,请使用控制台或EB CLI检查/var/log/eb-activity.log。

INFO: Command execution completed on all instances. INFO:在所有实例上完成命令执行。 Summary: [Successful: 0, Failed: 1]. 摘要:[成功:0,失败:1]。

ERROR: Unsuccessful command execution on instance id(s) 'i-80ee5327'. 错误:在实例标识'i-80ee5327'上执行命令失败。 Aborting the operation. 中止操作。

ERROR: Failed to deploy application. 错误:无法部署应用程序。

By reading error messages, I catch that the sqlite3 gem is not loadded by aws instance, so I put out the sqlite3 gem code to outside of development group. 通过读取错误消息,我发现sqlite3 gem没有被aws实例加载,因此我将sqlite3 gem代码放到开发组之外。

gem 'sqlite3', '~> 1.3.10' 

group :development, :test do
   ...other gems...
end
group :production do
   gem 'pg', '~> 0.18.1'
end

After that, the $ eb deploy command works well and server works. 之后, $ eb deploy命令运行良好,服务器正常工作。

So, my question is... WHY this problem happens? 所以,我的问题是......为什么会出现这个问题?

In my thought, if I make gemfile like 2nd version, sqlite3 adapter is loaded by default environment and should be crashing in production environment. 在我看来,如果我使gemfile像第二版一样,sqlite3适配器在默认环境下加载,应该在生产环境中崩溃。 But the result is completely opposite to me. 但结果与我完全相反。 This is very annoying situation and, to be more, I'm in doubt whether I'm doing the right solution. 这是非常烦人的情况,更重要的是,我怀疑我是否正在做正确的解决方案。

Please help me... 请帮我...

This is my current environment variables. 这是我目前的环境变量。

 RACK_ENV = development 
 SECRET_KEY_BASE = **********
 RAILS_SKIP_MIGRATIONS = false 
 RAILS_SKIP_ASSET_COMPILATION = false
 BUNDLE_WITHOUT = test:development

it appears you're running your beanstalk server in development mode. 看来你正在开发模式下运行beanstalk服务器。 make sure you have the following env variables set in beanstalk: 确保在beanstalk中设置了以下env变量:

RAILS_ENV=production
RACK_ENV=production

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

相关问题 使用Elastic Beanstalk错误将Rails部署到AWS上 - deploy ruby on rails to aws using Elastic Beanstalk error Rails 5 和 AWS Elastic Beanstalk 错误的数据库主机 - Rails 5 and AWS Elastic Beanstalk wrong database host 部署Rails应用时出现错误AWS弹性beantalk - error deploying rails app aws elastic beanstalk 为什么我的Rails应用程序无法部署到AWS Elastic Beanstalk? - Why is my Rails App failing to deploy to AWS Elastic Beanstalk? 无法将 Rails API 应用程序部署到 AWS Elastic Beanstalk - Unable to deploy Rails API app to AWS Elastic Beanstalk 在 AWS 弹性 beantalk 上使用 webpacker gem 部署 rails react 应用程序 - Deploy rails react app with webpacker gem on AWS elastic beanstalk Rails弹性Beanstalk无法部署 - - Rails elastic Beanstalk cannot deploy - 如何为 ruby 2.7.1 解决 AWS Elastic Beanstalk 上的 Rail 6 部署错误 - How to resolve Rail 6 deploy error on AWS Elastic Beanstalk for ruby 2.7.1 在Elastic Beanstalk环境上的Rails应用程序上部署ruby时发生AWS Database Migration Error - AWS Database Migration Error while deploying ruby on rails app on Elastic Beanstalk Environment 如何在 AWS Elastic Beanstalk 上为 Rails 应用程序设置数据库种子 - How do I seed a database for Rails app on AWS Elastic Beanstalk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM