2015-01-12 144 views
0

嗨我遇到了一個問題,這對我來說沒有意義。軌道控制檯工程,但軌道服務器不工作

在我的託管服務器上,我有一個我想運行的應用程序。我可以使用capistrano來部署應用程序。我也能夠毫無問題地運行bundle exec rails console production。但是,當我嘗試運行bundle exec rails server時,它將退出並顯示以下錯誤消息。

/home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:52:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:30:in `spec' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:39:in `establish_connection' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/railtie.rb:176:in `block (2 levels) in <class:Railtie>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:44:in `each' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/base.rb:322:in `<module:ActiveRecord>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/base.rb:22:in `<top (required)>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/orm/active_record.rb:3:in `<top (required)>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
    from /home/asavale1/rails_apps/dejalearn/releases/20150110214352/config/initializers/devise.rb:22:in `block in <top (required)>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise.rb:288:in `setup' 
    from /home/asavale1/rails_apps/dejalearn/releases/20150110214352/config/initializers/devise.rb:3:in `<top (required)>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/engine.rb:609:in `block (2 levels) in <class:Engine>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/engine.rb:608:in `each' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/engine.rb:608:in `block in <class:Engine>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `each' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `tsort_each_child' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:411:in `call' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `each' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `call' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each' 
    from /home/asavale1/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing' 
    from /home/asavale1/rails_apps/dejalearn/releases/20150110214352/config/environment.rb:5:in `<top (required)>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
    from /home/asavale1/rails_apps/dejalearn/releases/20150110214352/config.ru:3:in `block in <main>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize' 
    from /home/asavale1/rails_apps/dejalearn/releases/20150110214352/config.ru:in `new' 
    from /home/asavale1/rails_apps/dejalearn/releases/20150110214352/config.ru:in `<main>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap' 
    from /home/asavale1/rails_apps/dejalearn/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>' 
    from bin/rails:4:in `require' 
    from bin/rails:4:in `<main>' 

所以它好像不喜歡我的database.yml文件。這是我database.yml

production: 
    adapter: mysql2 
    database: asavale1_dejalearn 
    username: ENV['DB_USER'] 
    password: ENV['DB_PASS'] 
    pool: 5 
    timeout: 5000 

爲什麼我能夠運行bundle exec rails console production但抱怨適配器,當我嘗試運行我的Rails服務器。不要使用同一個databse.yml文件連接到數據庫嗎?我的RAILS_ENV是生產。

感謝

回答

2

它看起來像你明確地開始在生產環境中的控制檯,並在(默認)開發環境中的服務器。嘗試運行bundle exec rails server -e $RAILS_ENV。如果這不起作用,請嘗試bundle exec rails server -e production

+0

謝謝@AmeyaSavale。就像旁邊一樣,你可能不想在生產中使用'rails server'。查看諸如[thin](http://code.macournoyer.com/thin/)和[unicorn](http://unicorn.bogomips.org)等應用服務器。 – cdmwebs

+0

我一定會考慮一下,但問題是我不確定我是否可以下載外部軟件包。我必須通過我的虛擬主機提供商來解決這個問題,謝謝你的信息 –