部署 部署后登录:提示 Web application could not be started

sensi · 2014年05月14日 · 最后由 sensi 回复于 2014年05月14日 · 6705 次阅读

database.yml

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: mysql2
  database: date_around
  pool: 5
  timeout: 5000
  username: root
  encoding: utf8
  host: localhost
  # password: 

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  database: date_around
  pool: 5
  timeout: 5000
  username: root
  encoding: utf8
  host: localhost
  password: 

production:
  adapter: mysql2
  database: date_around
  pool: 5
  timeout: 5000
  username: root
  encoding: utf8
  host: localhost
  password: 

数据库配置如上,

错误信息如下

database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:52:in `resolve_hash_connection'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:30:in `spec'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_handling.rb:39:in `establish_connection'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/railtie.rb:176:in `block (2 levels) in <class:Railtie>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:44:in `each'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/base.rb:322:in `<module:ActiveRecord>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/base.rb:22:in `<top (required)>'
  /home/root/www/sample_app/app/models/user.rb:1:in `<top (required)>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:330:in `require_or_load'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:289:in `depend_on'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:207:in `require_dependency'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/engine.rb:464:in `each'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/engine.rb:464:in `block in eager_load!'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/engine.rb:462:in `each'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/engine.rb:462:in `eager_load!'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/engine.rb:347:in `eager_load!'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/application/finisher.rb:56:in `each'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `instance_exec'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `run'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:55:in `block in run_initializers'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:54:in `run_initializers'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/application.rb:215:in `initialize!'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /home/root/www/sample_app/config/environment.rb:5:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.39/helper-scripts/rack-preloader.rb:112:in `eval'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.39/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.39/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.39/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/rvm/gems/ruby-2.0.0-p451/gems/passenger-4.0.39/helper-scripts/rack-preloader.rb:28:in `<main>'

上面说数据库不适配,我的 database.yml 设置跟另一个运行正常的的文件模板一样的,我想不是 database.yml 的原因。。

————————————————————————————

还有一个重要的信息:::项目启动了之后,数据库中没有生成对应的数据库!

运行一个叫做 rain 的项目能够正常运转,换成别的项目就不行了,(nginx.conf 已经修改),已经尝试多个项目,都无法正常运行,,

rake db:migrate 这个?

#1 楼 @hging 实在服务器中部署额!!部署完后直接启动项目了!!!我记得不需要自行迁移数据库!

#2 楼 @sensi 你是怎么部署的呢 - - 直接 rails s?

bundle install
RAILS_ENV=production rake db:create
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake db:seed
RAILS_ENV=production rake assets:precompile
rails s -e production

#3 楼 @hging sudo /etc/init.d/nginx restart 很早之前有一个项目在这运行,现在换了项目,一直部署不成功

#5 楼 @sensi ........看 4L 并且 nginx 只是个代理啊。没起程序啊。

#6 楼 @hging 已经通过四楼的方式 运行成功 谢谢,,,但是图片上传不能成功!开发的时候上传是成功的!

#7 楼 @sensi 果然还是没有添加数据库。嘿嘿。那你图片上传的话是怎么上传的么。具体有没有什么报错信息 and 代码呢。

#8 楼 @hging用 carrierwave 上传的,访问页面给的错误提示是:If you are the application owner check the logs for more information. 但是 production.log 里面没有任何的信息,

需要 登录 后方可回复, 如果你还没有账号请 注册新账号