访问AWS上的Rails应用程序时出错:数据库配置未指定适配器

时间:2015-03-11 12:03:35

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

我一直在尝试开始在AWS'Elastic Beanstalk上运行Rails,在运行我的rails应用程序时,会出现以下错误。

而不是看到我的rails应用程序(顺便说一句,在本地运行正常),我得到了可怕的“我们很抱歉,但出了点问题”页面: enter image description here

的database.yml

production:
  adapter: postgresql
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

日志

/var/app/support/logs/passenger.log

App 3676 stdout: 
App 3676 stdout: 
[ 2015-03-11 11:06:44.6211 3139/7f7bba716700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /var/app/current: An error occured while starting up the preloader.
  Error ID: 444a4118
  Error details saved to: /tmp/passenger-error-jgrbjG.html
  Message from application: database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `each'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/railtie.rb:80:in `block in <class:Railtie>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `instance_exec'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `run'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:55:in `block in run_initializers'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `each'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `run_initializers'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/application.rb:136:in `initialize!'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /var/app/current/config/environment.rb:5:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:112:in `eval'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:28:in `<main>'


[ 2015-03-11 11:06:44.6322 3139/7f7bb3fff700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning error occurred. The identifier of the error is 444a4118. Please see earlier logs for details about the error.
[ 2015-03-11 11:06:44.6324 3139/7f7bb3fff700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 26] Cannot checkout session because a spawning error occurred. The identifier of the error is 444a4118. Please see earlier logs for details about the error.
App 3749 stdout: 
App 3749 stdout: 
[ 2015-03-11 11:13:58.5266 3139/7f7bba716700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /var/app/current: An error occured while starting up the preloader.
  Error ID: 04ef27b3
  Error details saved to: /tmp/passenger-error-vFuwfd.html
  Message from application: database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `each'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/railtie.rb:80:in `block in <class:Railtie>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `instance_exec'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `run'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:55:in `block in run_initializers'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `each'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `run_initializers'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/application.rb:136:in `initialize!'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /var/app/current/config/environment.rb:5:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:112:in `eval'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/helper-scripts/rack-preloader.rb:28:in `<main>'


[ 2015-03-11 11:13:58.5380 3139/7f7bb3fff700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning error occurred. The identifier of the error is 04ef27b3. Please see earlier logs for details about the error.
[ 2015-03-11 11:13:58.5382 3139/7f7bb3fff700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 26] Cannot checkout session because a spawning error occurred. The identifier of the error is 04ef27b3. Please see earlier logs for details about the error.

请帮忙。

1 个答案:

答案 0 :(得分:1)

好像忘记在adapter中指定config/database.yml配置选项:

production:
  ...
  adapter: postgresql
  ...

Here代码行引发了您的错误。如您所见,在连接规范中检查adapter密钥。