尝试在生产环境中启动 rails 服务器



Rails服务器无法在生产环境中启动,我认为与数据库存在冲突,我应该迁移它们还是其他方式?

=> Booting Puma
=> Rails 5.0.6 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Exiting
/home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.rb:170:in
`spec': database configuration does not specify adapter
(ActiveRecord::AdapterNotSpecified)
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_handling.rb:53:in `establish_connection'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.6/lib/active_record/railtie.rb:125:in `block (2 levels) in <class:Railtie>'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:41:in `block in on_load'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:40:in `each'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:40:in `on_load'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.6/lib/active_record/railtie.rb:121:in `block in <class:Railtie>'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `instance_exec'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `run'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:54:in `run_initializers'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/application.rb:352:in `initialize!'
from /home/user/Desktop/upgraded-carnival/config/environment.rb:5:in `<top (required)>'
from /home/user/Desktop/upgraded-carnival/config.ru:3:in `require_relative'
from /home/user/Desktop/upgraded-carnival/config.ru:3:in `block in <main>'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
from /home/user/Desktop/upgraded-carnival/config.ru:in `new'
from /home/user/Desktop/upgraded-carnival/config.ru:in `<main>'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands/server.rb:84:in `app'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands/server.rb:104:in `start'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

我的数据库.yml :

default: &default   
adapter: postgresql   
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
production:
host: localhost
database: magnetcoin_production  
pool:     10   
timeout:  10000   
username: magnetcoin   
password:
magnetcoin   template: template0
development:   <<: *default   
database: magnetcoin_development
test:   <<: *default   
database: magnetcoin_test

根据日志,您没有为生产环境数据库配置定义适配器。您在默认块中添加了适配器,但未将默认适配器导入生产块。只需在生产块中导入默认块,一切都可以正常工作。

default: &default 
adapter: postgresql 
encoding: unicode 
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 
production: <<: *default
host: localhost 
database: magnetcoin_production 
pool: 10 
timeout: 10000 
username: magnetcoin 
password: magnetcoin 
template: template0 
development: <<: *default 
database: magnetcoin_development 
test: <<: *default 
database: magnetcoin_test

最新更新