Rails应用程序在本地工作正常,但heroku给出“应用程序错误”

时间:2013-11-04 17:06:27

标签: ruby-on-rails ruby-on-rails-3 heroku heroku-toolbelt

  

应用程序中发生错误,您的页面无法执行   提供服务。请稍后再试。

     

如果您是应用程序所有者,请查看日志以获取详细信息。

enter image description here

这是$ 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

1 个答案:

答案 0 :(得分:0)

我认为值得尝试在heroku而不是webrick上运行unicorn。由于某种原因,Heroku在运行其他网络服务器时变得非常糟糕。去年我跑得很好,但是今年,当我有一些代码要更新并试图上传到heroku时,Thin正在打破heroku。

  1. 添加gem 'unicorn'
  2. bundle install
  3. 创建config/unicorn.rb
  4. config/unicorn.rb
  5. 中添加以下内容
    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
    

    最后提交更改并推送到heroku