将Rails应用程序部署到Heroku会导致崩溃

时间:2014-07-23 07:20:02

标签: heroku ruby-on-rails-4

这个答案似乎已经以各种方式得到了解答,但没有一个似乎符合我的确切问题。我正在使用RailsApps https://github.com/RailsApps/rails-devise-pundit

中的应用

该应用程序在我当地的Ubuntu 14.04计算机上运行良好,但当我将其部署到Heroku时,我收到了一个“应用程序错误”。在页面上我的应用程序应该已经启动。我跑了' heroku日志'但无法确定究竟是什么问题。下面是我的日志以及我的Gem文件。任何帮助将不胜感激。谢谢。

这是我的日志

2014-07-23T07:01:02.819470+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
2014-07-23T07:01:02.819467+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
2014-07-23T07:01:02.819544+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
2014-07-23T07:01:02.819471+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:648:in `block in load_config_initializer'
2014-07-23T07:01:02.819499+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
2014-07-23T07:01:02.819476+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:647:in `load_config_initializer'
2014-07-23T07:01:02.819485+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
2014-07-23T07:01:02.819488+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run'
2014-07-23T07:01:02.819497+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
2014-07-23T07:01:02.819550+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
2014-07-23T07:01:02.819553+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
2014-07-23T07:01:02.819551+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
2014-07-23T07:01:02.819554+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
2014-07-23T07:01:02.819559+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
2014-07-23T07:01:02.819560+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2014-07-23T07:01:02.819564+00:00 app[web.1]:    from config.ru:4:in `require'
2014-07-23T07:01:02.819569+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2014-07-23T07:01:02.819570+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2014-07-23T07:01:02.819574+00:00 app[web.1]:    from config.ru:1:in `new'
2014-07-23T07:01:02.819566+00:00 app[web.1]:    from config.ru:4:in `block in <main>'
2014-07-23T07:01:02.819511+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
2014-07-23T07:01:02.819482+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:611:in `each'
2014-07-23T07:01:02.819580+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
2014-07-23T07:01:02.819583+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
2014-07-23T07:01:02.
819575+00:00 app[web.1]:        from config.ru:1:in `<main>'
2014-07-23T07:01:02.819584+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
2014-07-23T07:01:02.819589+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2014-07-23T07:01:02.819612+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>'
2014-07-23T07:01:02.819578+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
2014-07-23T07:01:02.819557+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
2014-07-23T07:01:02.819494+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
2014-07-23T07:01:02.819546+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
2014-07-23T07:01:02.819587+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:137:in `start'
2014-07-23T07:01:02.819611+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
2014-07-23T07:01:04.031160+00:00 heroku[web.1]: State changed from starting to crashed
2014-07-23T07:01:04.733648+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=86caffee-16f4-4f06-a6d8-7930d96c7135 fwd="54.237.152.106" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:04.020673+00:00 heroku[web.1]: Process exited with status 1
2014-07-23T07:01:00.263828+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 5019 -c ./config/unicorn.rb`
2014-07-23T07:01:17.938391+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=96c1bf22-04ca-408b-b2c5-6a6282763eb2 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:21.119579+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=14e4d82e-c91f-49eb-bd81-d689e6f0f75a fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:22.528876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=343a0401-da9f-4ec6-99a1-70489632e40b fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:24.008236+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=47981f94-e284-4b18-bec2-282f656e5289 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:25.044701+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.co
m request_id=56593500-3931-4e5f-a44d-1b65879dff76 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:27.515189+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=d7b8d1b8-272a-4f05-b962-88e74fb27647 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:29.495853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=15f0a28d-9d90-4114-bdc2-86ced1502757 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:01:52.893456+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=08f79ef3-8a34-4098-856e-6a841bbc9214 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=
2014-07-23T07:08:27.346505+00:00 heroku[web.1]: State changed from crashed to starting
2014-07-23T07:08:32.470674+00:00 app[web.1]: I, [2014-07-23T07:08:32.470553 #2]  INFO -- : Refreshing Gem list
2014-07-23T07:08:33.337873+00:00 app[web.1]:    from /app/config/initializers/devise.rb:13:in `block in <top (required)>'
2014-07-23T07:08:33.337880+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
2014-07-23T07:08:33.337886+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
2014-07-23T07:08:33.337893+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:647:in `load_config_initializer'
2014-07-23T07:08:33.337883+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
2014-07-23T07:08:33.337888+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:648:in `block in load_config_initializer'
2014-07-23T07:08:33.337922+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
2014-07-23T07:08:33.337926+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
2014-07-23T07:08:33.337865+00:00 app[web.1]: /app/config/initializers/devise.rb:13:in `+': no implicit conversion of nil into String (TypeError)
2014-07-23T07:08:33.337889+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/notifications.rb:161:in `instrument'
2014-07-23T07:08:33.337894+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
2014-07-23T07:08:33.337918+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
2014-07-23T07:08:33.337876+00:00 app[web.1]:    from /app/config/initializers/devise.rb:3:in `<top (required)>'
2014-07-23T07:08:33.337881+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
2014-07-23T07:08:33.337940+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
2014-07-23T07:08:33.337874+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise.rb:288:in `setup'
2014-07-23T07:08:33.337898+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:611:in `each'
2014-07-23T07:08:33.337929+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:44:in `tsort_each_child'
2014-07-23T07:08:33.337932+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `call'
2014-07-23T07:08:33.337900+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>'
2014-07-23T07:08:33.337905+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/ra
ilties-4.1.4/lib/rails/initializable.rb:30:in `run'
2014-07-23T07:08:33.337908+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers'
2014-07-23T07:08:33.337923+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
2014-07-23T07:08:33.337935+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
2014-07-23T07:08:33.337936+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
2014-07-23T07:08:33.337903+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
2014-07-23T07:08:33.337925+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
2014-07-23T07:08:33.337927+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:44:in `each'
2014-07-23T07:08:33.337953+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
2014-07-23T07:08:33.337934+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
2014-07-23T07:08:33.337946+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
2014-07-23T07:08:33.337943+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
2014-07-23T07:08:33.337979+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2014-07-23T07:08:33.337954+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
2014-07-23T07:08:33.337974+00:00 app[web.1]:    from config.ru:4:in `require'
2014-07-23T07:08:33.337982+00:00 app[web.1]:    from config.ru:1:in `new'
2014-07-23T07:08:33.337972+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2014-07-23T07:08:33.337950+00:00 app[web.1]:    from /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
2014-07-23T07:08:33.337978+00:00 app[web.1]:    from config.ru:4:in `block in <main>'
2014-07-23T07:08:33.337984+00:00 app[web.1]:    from config.ru:1:in `<main>'
2014-07-23T07:08:33.337981+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2014-07-23T07:08:33.337986+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
2014-07-23T07:08:33.337985+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
2014-07-23T07:08:33.337988+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
2014-07-23T07:08:33.337996+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
2014-07-23T07:08:33.337991+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
2014-07-23T07:08:33.337993+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:137:in `start'
2014-07-23T07:08:33.337994+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2014-07-23T07:08:33.337997+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>'
2014-07-23T07:08:34.476119+00:00 heroku[web.1]: State changed from starting to crashed
2014-07-23T07:08:30.884736+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 40495 -c ./config/unicorn.rb`
2014-07-23T07:08:34.441069+00:00 heroku[web.1]: Process exited with status 1
2014-07-23T07:12:52.276241+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cfilink.herokuapp.com request_id=74ecf2fe-bcc2-4beb-9d0c-09be5181e4d8 fwd="99.169.168.250" dyno= connect= service= status=503 bytes=

这是我的Gem文件

source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.4'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'spring',        group: :development
gem 'bootstrap-sass'
gem 'devise', '~> 3.2.4'
gem 'devise_invitable'
gem 'pg'
gem 'pundit'
gem 'unicorn'
gem 'unicorn-rails'
gem 'figaro'
gem 'rails_12factor', '~> 0.0.2'
group :development do
  gem 'better_errors'
  gem 'binding_of_caller', :platforms=>[:mri_21]
  gem 'guard-bundler'
  gem 'guard-rails'
  gem 'guard-rspec'
  gem 'hub', :require=>nil
  gem 'quiet_assets'
  gem 'rails_layout'
  gem 'rb-fchange', :require=>false
  gem 'rb-fsevent', :require=>false
  gem 'rb-inotify', :require=>false
end
group :development, :test do
  gem 'factory_girl_rails'
  gem 'rspec-rails'
end
group :test do
  gem 'capybara'
  gem 'database_cleaner'
  gem 'faker'
  gem 'launchy'
  gem 'selenium-webdriver'
end

我的secretts.yml文件

development:
  admin_name: First User
  admin_email: user@example.com
  admin_password: changeme
  email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
  email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
  domain_name: example.com
  secret_key_base: 7032833bb8e9bf8f3d46ad9b886aca9bb41a0d92adb3c1080570e24bdb31459d240f58721d7681b2486d5d9d352a608feb434be880c507155e719a9dfe678b19

test:
  domain_name: example.com
  secret_key_base: 0de0958bbdd2608a2e1a4378660d4ec4f50b2df23cd85f5508c5bb1c821cb129bc9f799421deb622950c0e3ba7e344d8ee3fe693b8b162aa4b685907ff8df13e

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
  admin_name: <%= ENV["ADMIN_NAME"] %>
  admin_email: <%= ENV["ADMIN_EMAIL"] %>
  admin_password: <%= ENV["ADMIN_PASSWORD"] %>
  email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
  email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
  domain_name: <%= ENV["DOMAIN_NAME"] %>
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

我的application.yml文件(figaro gem)

GMAIL_USERNAME: myusername@gmail.com
GMAIL_PASSWORD: mypassword
DOMAIN_NAME: studiorooster.com

1 个答案:

答案 0 :(得分:9)

这才是真正导致错误的原因

/app/config/initializers/devise.rb:13

如果您仍然在13中使用此代码

 config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name

然后原因是Rails.application.secrets.domain_name是零。在Heroku上你必须通过环境变量设置秘密,并在生产部分的erb parsed secrets.yml中读取它们

e.g
#secrets.yml

 development:  

   domain_name: example.com

production:
   domain_name: <%= ENV['DOMAIN_NAME'] %>