1

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: enter image description here

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?

Community
  • 1
  • 1
seanicus
  • 1,141
  • 4
  • 19
  • 40

2 Answers2

3

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.

Community
  • 1
  • 1
Rohit Banga
  • 18,458
  • 31
  • 113
  • 191
  • I'll give this a whirl first thing in the morning... thanks for the tip! I assume the config file entry is what will make this work when new instances are spun up by the beanstalk? – seanicus Jun 16 '14 at 04:49
  • did as you suggested and added the config file. I am still getting the same error in the passenger log. I logged on to the instance to verify that sqlite-devel was installed by running "yum install sqlite-devel" which yielded the result: "Package sqlite-devel-3.7.17-1.9.amzn1.x86_64 already installed and latest version" I appreciate your help with this... do you have another suggestion? – seanicus Jun 16 '14 at 14:26
  • Does your app work locally? Also with the ebextension above did you try on a new environment. Another guess https://github.com/rails/rails/issues/11208 – Rohit Banga Jun 16 '14 at 15:26
  • Also rails 4 changed some stuff sobthat you no longer see the sample app page in a production environment https://github.com/rails/rails/pull/8468 If your app is working on localhost but not after deployment can you try defining a custom rails controller. Also which ruby puma solution stack did uou try with. Can you give the exact namd like 64bit Amazon Linux ... – Rohit Banga Jun 16 '14 at 15:34
  • Yes, the app works locally. And yes, I did try a whole new environment and rails app. Also, just tried running 'rails server' on the eb instance and got the same sqlite error. The instance I did for the most recent test was #27 in the list: "1.9.3 on 64bit Amazon Linux 2014.03 v1.0.3". When I tried it with Puma last week it was "2.0 (Puma) on Amazon Linux 2014.03 v1.0.4". – seanicus Jun 16 '14 at 15:45
  • Repeated entire experiment again for Puma with a custom rails controller, installing sqlite-devel as described above via config file. Still getting the "Maytag" error. – seanicus Jun 16 '14 at 16:41
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/55734/discussion-between-rohit-banga-and-seanicus). – Rohit Banga Jun 17 '14 at 00:24
  • Updated the answer with a possible error I have seen before. – Rohit Banga Jun 17 '14 at 00:24
0

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.

Hongli
  • 18,682
  • 15
  • 79
  • 107
  • Any thoughts as to getting the sqlite3 gem properly installed? I assume just re-running gem install is not sufficient, since I've tried that already. – seanicus Jun 13 '14 at 14:07
  • Sorry, I'm not familiar enough with Elastic Beanstalk to answer that. – Hongli Jun 13 '14 at 17:16