简体   繁体   中英

Trying to start rails server in production environment

Rails server doesn't starting in production environment, i think that there is a conflict with databases, should i migrate them or smth else?

=> 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>'

My database.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

As per you logs you did not define the adaptor for your production env database config. You added the adaptor in default block but did not import default to production block. Just import default block in production block and every thing works fine.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM