Rails app doesn't run on AWS Elastic Beanstalk, sqlite3 error

最后都变了- 提交于 2020-01-06 04:24:05

问题


I have been trying to get started running Rails on AWS' Elastic Beanstalk, but I have run in to a seemingly insurmountable obstacle: While I am able to spin up a new Elastic Beanstalk running the sample application, I cannot seem to get an EB instance to successfully run my own code.

Here are the steps I have taken:

  1. Locally running ruby 1.9.3p545 on OSX 10.9.3
  2. Installed aws-eb client tools.
  3. Scrupulously followed the following tutorial from Amazon: Deploying a Rails Application to AWS Elastic Beanstalk (tl;dnr: use 'rails new' to create a new rails app, commit to git and then use 'eb init' to create an EB instance of the type '64bit Amazon Linux 2014.03 v1.0.3 running Ruby 1.9.3' and then running 'eb start')
  4. After waiting a seeming eternity for the EB instance to be created, I navigate to the url Amazon provides.
  5. Instead of seeing my rails app (which, by the way, runs fine locally), I get the dreaded "We're sorry, but something went wrong" page:

I have tried these steps multiple times, with the same results. I have tried using different environments (the Ruby 2.0.0 Puma and Passenger ones, for instance, updating my ruby via rvm as necessary).

Before this is flagged as a duplicate, let me state straight away that I have looked at the following questions and found that they have not solved my problem:

AWS Elastic Beanstalk: Launching a new Rails App

Deploying an existing Rails app to AWS Elastic Beanstalk

Following the advice in the question "AWS Elastic Beanstalk: Launching a new Rails App", which seems very similar to my issue, I let the app run over night and I am still getting the error.

I've ssh'd in to the instance. Interestingly, both production.log and development.log appear to be empty (the ones in /var/app/support/logs, anyway). However, I find the following in passenger.log:

********* snip *********

[ 2014-06-12 21:42:38.8400 5133/7fe66aee4700 agents/HelperAgent/RequestHandler.h:2210 ]: [Client 20] Cannot checkout session. Error page: cannot load such file -- 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:inrescue 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:inrequire' /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:ineach' /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:ineach' /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:inrequire' /var/app/current/config/application.rb:7:in <top (required)>' /var/app/current/config/environment.rb:2:inrequire' /var/app/current/config/environment.rb:2:in <top (required)>' config.ru:3:inrequire' config.ru:3:in block in <main>' /usr/local/share/gems1.9/gems/rack-1.5.2/lib/rack/builder.rb:55:ininstance_eval' /usr/local/share/gems1.9/gems/rack-1.5.2/lib/rack/builder.rb:55:in initialize' config.ru:1:innew' config.ru:1:in <main>' /usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:ineval' /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 stdout: App 5241 stdout: [ 2014-06-12 21:45:26.2512 5133/7fe66d1ef700 Pool2/Implementation.cpp:883 ]: Could not spawn process for group /var/app/current#default: An error occured while starting up th$ in 'void Passenger::ApplicationPool2::SmartSpawner::handleErrorResponse(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:455) in 'std::string Passenger::ApplicationPool2::SmartSpawner::negotiatePreloaderStartup(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:566) in 'void Passenger::ApplicationPool2::SmartSpawner::startPreloader()' (SmartSpawner.h:206) in 'virtual Passenger::ApplicationPool2::ProcessPtr Passenger::ApplicationPool2::SmartSpawner::spawn(const Passenger::ApplicationPool2::Options&)' (SmartSpawner.h:752) in 'void Passenger::ApplicationPool2::Group::spawnThreadRealMain(const Passenger::ApplicationPool2::SpawnerPtr&, const Passenger::ApplicationPool2::Options&, unsigned in$

******** end snip ********

Not sure if sqlite3 is the problem or not, but it does appear to be installed on the instance. Just in case, I installed the sqlite3 gem again.

Here is the output of passenger-status:

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

I'm no expert, but it seems like passenger isn't running (processes == 0).

What am I missing? Is there some "JUST_WORK_DARNIT" config that I have neglected to set to true?

If, in fact, there is an issue with the sqlite3 install, as is suggested below, what can I do to resolve the issue?


回答1:


Can you try installing sqlite-devel by running yum install sqlite-devel?

You may want to use ebextensions to try this out on beanstalk. Try creating a file with path .ebextensions/00-myfile.config in your app source directory before deploying to beanstalk.

packages:
    yum:
        sqlite-devel: []

Sounds similar to the problem discussed here Why can't I install the SQLite gem?

Let me know if that works.

Update

There is one thing that changed with Rails 4. Possibly you are hitting this issue. See the discussion here: https://github.com/rails/rails/pull/8468 The default sample app generated by rails 4 does not work in production mode because of the above change. You can however make it work by modifying the sample app to include a non-default web page.

I tried the following: After running "rails new appname", "git init", "eb init" try the following steps. (Based on this answer).

  1. Edit config/routes.rb so that it contains root :to => 'proto#index'
  2. Create app/controllers/proto_controller.rb with the following contents

    class ProtoController < ApplicationController
    
      def index
      end
    
    end
    
  3. Create file app/views/proto/index.html.erb and write something in that file ... 'Hello World'.

Then launch your environment. That should work. When I try without following the above three steps then I also get an error page. But with these changes I do not see an error page.

I would recommend you perform the above steps in a fresh directory on a new environment. I tested with the latest Ruby solution stack "64bit Amazon Linux 2014.03 v1.0.4 running Ruby 2.0 (Puma)".

Also at some point when you get to Step 6 on this tutorial, you might end up replacing gem 'sqlite3' with gem 'mysql2' but that is the next step after you get the sample app running.




回答2:


Yes, the sqlite3 gem is the problem. It is installed, but not correctly installed. A key file (namely the sqlite3_native library file) is missing.



来源:https://stackoverflow.com/questions/24206699/rails-app-doesnt-run-on-aws-elastic-beanstalk-sqlite3-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!