ruby-on-rails - Rails应用程序无法在AWS Elastic Beanstalk上运行,sqlite3错误

标签 ruby-on-rails amazon-web-services sqlite passenger amazon-elastic-beanstalk

我一直试图开始在AWS的Elastic Beanstalk上运行Rails,但是遇到了一个看似无法克服的障碍:虽然我能够启动一个运行示例应用程序的新Elastic Beanstalk,但似乎无法获得EB实例。成功运行我自己的代码。

这是我已采取的步骤:


在OSX 10.9.3上本地运行ruby 1.9.3p545
已安装aws-eb客户端工具。
严格遵循Amazon的以下教程:Deploying a Rails Application to AWS Elastic Beanstalk(tl; dnr:使用'rails new'创建新的Rails应用程序,提交到git,然后使用'eb init'创建类型为'64bit Amazon Linux'的EB实例。 2014.03 v1.0.3运行Ruby 1.9.3',然后运行“ eb start”)
等待似乎永恒的创建EB实例后,我导航到Amazon提供的URL。
而不是看到我的rails应用程序(顺便说一句,该应用程序在本地运行良好),我得到的是可怕的“很抱歉,但是出了点问题”页面:



我已经尝试了多次这些步骤,但结果相同。我尝试使用不同的环境(例如Ruby 2.0.0 Puma和Passenger的环境,必要时通过rvm更新我的红宝石)。

在将此标记为重复之前,让我立即声明我已经看过以下问题,发现它们没有解决我的问题:

AWS Elastic Beanstalk: Launching a new Rails App

Deploying an existing Rails app to AWS Elastic Beanstalk

遵循问题“ AWS Elastic Beanstalk:启动新的Rails应用程序”中的建议,该问题似乎与我的问题非常相似,我让该应用程序运行了一整夜,但仍然出现错误。

我已经进入实例了。有趣的是,production.log和development.log似乎都是空的(无论如何,在/ var / app / support / logs中都是这样)。但是,我在passenger.log中找到以下内容:

*********片段*********

[2014-06-12 21:42:38.8400 5133 / 7fe66aee4700 agent / HelperAgent / RequestHandler.h:2210]:[客户端20]无法签出会话。
错误页面:
无法加载此类文件-sqlite3 / sqlite3_native(LoadError)
/usr/local/share/gems1.9/gems/sqlite3-1.3.9/lib/sqlite3.rb:6:in require' /usr/local/share/gems1.9/gems/sqlite3-1.3.9/lib/sqlite3.rb:6:in中的'
/usr/local/share/gems1.9/gems/sqlite3-1.3.9/lib/sqlite3.rb:2:in <top (required)>' /usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in require'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in block (2 levels) in require' /usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in each'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in block in require' /usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in each'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in require' /usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler.rb:132:in require'
/var/app/current/config/application.rb:7:in <top (required)>' /var/app/current/config/environment.rb:2:in require'
/var/app/current/config/environment.rb:2:in <top (required)>' config.ru:3:in require'
config.ru:3:在block in <main>' /usr/local/share/gems1.9/gems/rack-1.5.2/lib/rack/builder.rb:55:in instance_eval'中
/usr/local/share/gems1.9/gems/rack-1.5.2/lib/rack/builder.rb:55:in initialize' config.ru:1:in new'
config.ru:1:在<main>' /usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in评估'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in preload_app' /usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:158:in'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:29:in <module:PhusionPassenger>' /usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:28:in'

App 5241标准输出:
App 5241标准输出:
[2014-06-12 21:45:26.2512 5133 / 7fe66d1ef700 Pool2 / Implementation.cpp:883]:无法生成组/ var / app / current#default的进程默认:启动th $时发生错误
在'void Passenger :: ApplicationPool2 :: SmartSpawner :: handleErrorResponse(Passenger :: ApplicationPool2 :: SmartSpawner :: StartupDetails&)'(SmartSpawner.h:455)中
在'std :: string Passenger :: ApplicationPool2 :: SmartSpawner :: negotiatePreloaderStartup(Passenger :: ApplicationPool2 :: SmartSpawner :: StartupDetails&)'中(SmartSpawner.h:566)
在“ void Passenger :: ApplicationPool2 :: SmartSpawner :: startPreloader()”中(SmartSpawner.h:206)
在'虚拟乘客:: ApplicationPool2 :: ProcessPtr乘客:: ApplicationPool2 :: SmartSpawner :: spawn(const乘客:: ApplicationPool2 :: Options&)'(SmartSpawner.h:752)中
在'void乘客:: ApplicationPool2 :: Group :: spawnThreadRealMain(const乘客:: ApplicationPool2 :: SpawnerPtr&,const乘客:: ApplicationPool2 :: Options&,未签名

********结束片段********

不确定sqlite3是否是问题所在,但似乎确实已在实例上安装了它。以防万一,我再次安装了sqlite3 gem。

这是旅客状态的输出:

Version : 4.0.41
Date    : 2014-06-13 13:25:52 +0000
Instance: 5148
----------- General information -----------
Max pool size : 6
Processes     : 0
Requests in top-level queue : 0

----------- Application groups -----------
/var/app/current#default:
App root: /var/app/current
Requests in queue: 0


我不是专家,但似乎乘客不在运行(进程== 0)。

我想念什么?是否有一些我忽略设置为true的“ JUST_WORK_DARNIT”配置?

如果实际上sqlite3安装存在问题(如下所示),我该怎么做才能解决该问题?

最佳答案

您可以通过运行yum install sqlite-devel尝试安装sqlite-devel吗?

您可能要使用ebextensions在beantalk上进行尝试。
在部署到beantalk之前,请尝试在应用程序源目录中创建路径为.ebextensions/00-myfile.config的文件。

packages:
    yum:
        sqlite-devel: []


听起来与这里讨论的问题相似Why can't I install the SQLite gem?

让我知道是否可行。

更新资料

Rails 4改变了一件事情。可能是您遇到了这个问题。
请参阅此处的讨论:https://github.com/rails/rails/pull/8468
由于上述更改,由Rails 4生成的默认示例应用程序无法在生产模式下运行。但是,您可以通过修改示例应用程序以使其包含非默认网页来使其工作。

我尝试了以下方法:
运行“ rails new appname”,“ git init”,“ eb init”后,请尝试以下步骤。 (基于this答案)。


编辑config / routes.rb,使其包含root :to => 'proto#index'
使用以下内容创建app / controllers / proto_controller.rb

class ProtoController < ApplicationController

  def index
  end

end

创建文件app / views / proto / index.html.erb并在该文件中写一些东西……“ Hello World”。


然后启动您的环境。那应该工作。
当我尝试不遵循上述三个步骤时,我还会收到一个错误页面。但是通过这些更改,我看不到错误页面。

我建议您在新环境中的新目录中执行上述步骤。我使用最新的Ruby解决方案堆栈“运行Ruby 2.0(Puma)的64位Amazon Linux 2014.03 v1.0.4”进行了测试。

同样,当您进入this教程的第6步时,最终可能会用gem'mysql2'替换gem'sqlite3',但这是运行示例应用程序之后的下一步。

关于ruby-on-rails - Rails应用程序无法在AWS Elastic Beanstalk上运行,sqlite3错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24206699/

相关文章:

amazon-web-services - 如何在 Docker 容器中创建 DynamoDB(本地)表

java - 如何在数据库中正确添加图像和字符串?

c++ - SQLite 和结帐语义

ruby-on-rails - 如何加快在 Google Cloud Platform 上部署 Rails Docker?

amazon-web-services - 为多个 ec-2 实例分配主机名的最佳方法

ruby-on-rails - Ruby on Rails 模型文件中的条件语句

amazon-web-services - 无法更改网络接口(interface)的安全组

python - 异常和 sqlite3

ruby-on-rails - 带有rails 4.1的Mongodb错误代码10068或17287并设计

ruby-on-rails - Ruby 不读取 database.yml 文件