Heroku应用程序每次尝试打开时都会崩溃

时间:2017-07-15 14:29:39

标签: ruby-on-rails heroku cloud9-ide

我尝试使用Heroku部署我的应用。我想我已经成功部署了它,但每当我尝试在浏览器上打开我的应用程序时,它就说......

  

应用程序错误应用程序和页面发生错误   无法提供服务。如果您是应用程序所有者,请检查日志   详情

当我输入heroku logs时,我得到......

2017-07-15T14:20:37.334994+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-15T14:20:38.012558+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=deucex.herokuapp.com request_id=8a0d5560-e3bb-4cc2-82c3-9258db8eacb5 fwd="98.26.96.65" dyno= connect= service= status=503 bytes= protocol=https

我知道我的应用程序崩溃了,但我不知道为什么。我尝试输入heroku restart,但没有工作。我也尝试过查找这个问题,但没有成功。我该怎么办?

======更新=====

当我进入时:

$ heroku run rake db:create

我收到以下错误:

FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"dd9p7e3qfv5v6k", "username"=>"dzkwulhdubxmkt", "password"=>"e3864a3452e40eb2586d5fc2f6052dd9e85e8fd59804151c4701ae046743e4a8", "port"=>5432, "host"=>"ec2-23-23-244-83.compute-1.amazonaws.com"}
rake aborted!
PG::ConnectionBad: FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.20.0/lib/pg.rb:56:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.20.0/lib/pg.rb:56:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.20.0/lib/pg.rb:56:in `connect'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_handling.rb:88:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/postgresql_database_tasks.rb:10:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/postgresql_database_tasks.rb:19:in `create'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:117:in `create'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:137:in `block in create_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:303:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:136:in `create_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/railties/databases.rake:27:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli.rb:360:in `exec'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli.rb:10:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/exe/bundle:35:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/exe/bundle:27:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)

=====更新========

当我尝试跑步时:

$ rails server -b $IP -p $PORT

我明白了:

  

ActiveRecord :: NoDatabaseError致命:数据库&#34; sale_development&#34;不   不存在

这是我的database.yml代码

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: sale_development

test:
  <<: *default
  database: sale_test

production:
  <<: *default
  database: sale_production
  username: sale
  password: <%= ENV['SALE_DATABASE_PASSWORD'] %>

显然sale_development存在。销售是我的应用程序的名称。为什么说它不存在?

宝石文件

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
 "https://github.com/#{repo_name}.git"
 end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use sqlite3 as the database for Active Record

#gem 'sqlite3'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass'
gem "paperclip", "~> 5.0.0"
gem 'devise', '~> 4.3'
gem 'will_paginate', '~> 3.0'


# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'pg'
end

group :development do
   # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'pg'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rails_12factor', group: :production

1 个答案:

答案 0 :(得分:1)

您是否创建了数据库? 尝试heroku run rake db:createheroku run rails db:create,然后迁移。

您收到消息sale_development不存在,因为当您推送到heroku时,它正在生产和生产中启动您的应用程序,您有另一个数据库。

  

已编辑

当我查看heroku日志时,我发现/app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in require': No such file to load -- test_helper.rb (LoadError)错误 Here already fix same error