简体   繁体   English

Rails应用程序在本地运行良好,但heroku给出“应用程序错误”

[英]Rails app works fine locally but heroku gives “application error”

An error occurred in the application and your page could not be served. 应用程序中发生错误,无法提供您的页面。 Please try again in a few moments. 请稍后重试。

If you are the application owner, check your logs for details. 如果您是应用程序所有者,请检查日志以获取详细信息。

在此处输入图片说明

This is output of $ heroku logs 这是$ heroku logs输出

2013-11-04T16:42:03.262057+00:00 app[web.1]: => Booting WEBrick
2013-11-04T16:42:03.262057+00:00 app[web.1]: => Call with -d to detach
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
2013-11-04T16:42:03.262057+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-11-04T16:42:03.262812+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': /app/app/controllers/comments_controller.rb:11: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:359:in `require_or_load'
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:436:in `eager_load!'
2013-11-04T16:42:03.262057+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:21573
2013-11-04T16:42:03.262057+00:00 app[web.1]: Exiting
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:438:in `block in eager_load!'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/config.ru:3:in `require'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:313:in `depend_on'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from script/rails:6:in `require'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:436:in `each'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
2013-11-04T16:42:03.262812+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:438:in `each'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/config.ru:in `new'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
2013-11-04T16:42:03.262959+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2013-11-04T16:42:03.263102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
2013-11-04T16:42:03.263481+00:00 app[web.1]:    from s
cript/rails:6:in `<main>'
2013-11-04T16:42:04.472335+00:00 heroku[web.1]: Process exited with status 1
2013-11-04T16:42:04.486507+00:00 heroku[web.1]: State changed from starting to crashed
2013-11-04T16:42:04.487147+00:00 heroku[web.1]: State changed from crashed to starting
2013-11-04T16:42:08.798959+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 25033`
2013-11-04T16:42:11.912925+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-11-04T16:42:11.912925+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-11-04T16:42:12.498245+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:25033
2013-11-04T16:42:12.498245+00:00 app[web.1]: Exiting
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
2013-11-04T16:42:12.498245+00:00 app[web.1]: => Call with -d to detach
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
2013-11-04T16:42:12.498245+00:00 app[web.1]: => Booting WEBrick
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:438:in `block in eager_load!'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
2013-11-04T16:42:12.498245+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
2013-11-04T16:42:12.499025+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': /app/app/controllers/comments_controller.rb:11: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:436:in `each'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/config.ru:in `new'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:313:in `depend_on'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:359:in `require_or_load'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:438:in `each'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from script/rails:6:in `require'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
2013-11-04T16:42:12.499025+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:436:in `eager_load!'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
2013-11-04T16:42:12.499167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/config.ru:3:in `require'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from script/rails:6:in `<main>'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
2013-11-04T16:42:12.499842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
2013-11-04T16:42:12.499310+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
2013-11-04T16:42:13.751522+00:00 heroku[web.1]: State changed from starting to crashed
2013-11-04T16:42:13.731563+00:00 heroku[web.1]: Process exited with status 1
2013-11-04T16:42:15.692293+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=protected-fjord-9847.herokuapp.com fwd="122.171.4.161" dyno= connect= service= status=503 bytes=
2013-11-04T16:42:17.108274+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=protected-fjord-9847.herokuapp.com fwd="122.171.4.161" dyno= connect= service= status=503 bytes=
2013-11-04T16:43:56.642434+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=protected-fjord-9847.herokuapp.com fwd="117.203.200.191" dyno= connect= service= status=503 bytes=
2013-11-04T16:42:14.944153+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=protected-fjord-9847.herokuapp.com fwd="122.171.4.161" dyno= connect= service= status=503 bytes=
2013-11-04T16:43:55.498175+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=protected-fjord-9847.herokuapp.com fwd="117.203.200.191" dyno= connect= service= status=503 bytes=

pastebin link http://pastebin.com/h5vTk4c0 pastebin链接http://pastebin.com/h5vTk4c0

I think it's worth trying to run unicorn on heroku instead of webrick. 我认为值得尝试在heroku而不是webrick上运行unicorn Heroku became terrible at running other webservers for some reason. Heroku由于某种原因而无法运行其他Web服务器。 I was running thin perfectly fine last year, but this year, when I had some code to update and tried to upload to heroku, Thin was breaking heroku. 去年,我的运行状况非常好,但是今年,当我有一些代码需要更新并尝试上传到heroku时,Thin打破了heroku。

  1. add gem 'unicorn' 添加gem 'unicorn'
  2. bundle install
  3. create config/unicorn.rb 创建config/unicorn.rb
  4. Add the following in config/unicorn.rb config/unicorn.rb添加以下config/unicorn.rb
config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true

before_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end 

after_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

Finally commit changes and push to heroku 最后提交更改并推送到heroku

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails在本地工作正常,但在heroku中没有 - Rails works fine locally but not in heroku 在heroku上部署Rails应用程序时遇到问题(该应用程序在本地运行良好)? - Having issues with deploying Rails app on heroku( app works fine locally)? Rails应用程序可以在本地使用载波在S3上正常运行,在Heroku上崩溃,并显示错误消息“无法自动加载常量” - Rails app works fine with S3 using carrierwave locally, crashes on Heroku with error message 'Unable to autoload constant' heroku 上的 Rails 未初始化常量错误,twitter api,在本地工作正常 - Rails uninitialized constant error on heroku, twitter api, works fine locally Rails 4-应用程序可在本地运行,但不能在Heroku上运行 - Rails 4 - App works locally, but not on Heroku Heroku rails 应用程序在本地运行,但打开时给出应用程序错误代码 H10 - Heroku rails app runs locally but gives application error code H10 when opened 我如何找出为什么Rails应用在Heroku上对单个特定URL抛出错误的同时在本地运行良好? - How could I find out why Rails app throws error for a single, specific URL on Heroku while it works fine locally? Heroku:Rails应用程序可在本地运行,但在Heroku上崩溃 - Heroku: Rails app works locally but crashes on heroku Rails应用程序-在本地可以正常运行,但不能在Heroku上运行 - Rails app - working fine locally but not on heroku Rails App可在本地运行,但在Heroku上生产时出现错误 - Rails App works locally but giving an error on production on Heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM