unicorn_rails命令失败并出现错误' development'数据库未配置

时间:2014-07-15 11:46:25

标签: ruby-on-rails-4 nginx unicorn digital-ocean

我在Digital Ocean上设置了带有rails 4,unicorn和nginx的rails服务器。 环境 - 分期 在尝试在Digital Ocean服务器上运行命令unicorn_rails时,我收到此错误:

I, [2014-07-15T07:35:34.206087 #7147]  INFO -- : listening on addr=0.0.0.0:8080 fd=9
I, [2014-07-15T07:35:34.206528 #7147]  INFO -- : worker=0 spawning...
I, [2014-07-15T07:35:34.207917 #7147]  INFO -- : master process ready
I, [2014-07-15T07:35:34.209513 #7173]  INFO -- : worker=0 spawned pid=7173
I, [2014-07-15T07:35:34.210202 #7173]  INFO -- : Refreshing Gem list
E, [2014-07-15T07:35:36.425768 #7173] ERROR -- : 'development' database is not configured. Available: ["default", "staging"] (ActiveRecord::AdapterNotSpecified)
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:224:in `resolve_connection'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:152:in `resolve'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:182:in `spec'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_handling.rb:50:in `establish_connection'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:129:in `block (2 levels) in <class:Railtie>'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:27:in `each'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
/home/deploy/mydoc/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
/home/deploy/mydoc/releases/20140715103735/config/environment.rb:5:in `<top (required)>'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
config.ru:4:in `block in <main>'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/bin/unicorn_rails:139:in `call'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/bin/unicorn_rails:139:in `block in rails_builder'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:628:in `init_worker_process'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:651:in `worker_loop'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/bin/unicorn_rails:209:in `<top (required)>'
/home/deploy/.rbenv/versions/2.1.2/bin/unicorn_rails:23:in `load'
/home/deploy/.rbenv/versions/2.1.2/bin/unicorn_rails:23:in `<main>'

Database.yml在服务器上看起来像这样:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

staging:
  <<: *default
  database: myapp
  host:     localhost
  username: deploy
  password: XXXXXX
  template: template0
  port:     5432

1 个答案:

答案 0 :(得分:0)

我认为您应该使用bundle exec unicorn -E staging启动它。

请参阅How to start rails server in production mode using unicorn and config file?