gpt4 book ai didi

ruby - 在 Heroku 上增加 dyno 数量后的错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:53:36 26 4
gpt4 key购买 nike

我在 Heroku 服务器上使用 Ruby 为 Facebook 编写了一个应用程序,一切都很顺利,直到我将测功机的数量增加到 2。此时,大约一半的时间我会去一个新页面,我会收到一条错误消息,否则我将返回主页,具体取决于我访问的页面。我通过返回一个 dyno 解决了这个问题,但我仍然不知道出了什么问题。有任何想法吗?代码可以在这里找到:

https://github.com/runninggraeb/toolshed

程序可以在这里找到(如果你感兴趣的话):

https://apps.facebook.com/toolshed

如有任何帮助,我们将不胜感激。

所有日志都粘贴在下面。请注意,错误消息是在我使用 dyno=web.1 之后开始的,然后是 dyno=web.2。

2013-03-10T22:34:54+00:00 heroku[router]: at=info method=GET path=/auth/facebook host=toolshed.herokuapp.com fwd="24.20.19.205" dyno=web.2 queue=0 wait=7ms connect=5ms service=10ms status=302 bytes=0
2013-03-10T22:34:57+00:00 app[web.1]: 24.20.19.205 - - [10/Mar/2013 22:34:57] "GET /auth/facebook/callback?code=AQC7B6vjC0ksefFLly76DMeqL-hHrR6M49lYgMqiAk01xmF-nbXC9pOAcd_e5x8KTycXcjfXG_ABRUmsfeQlusGECbL7d4PqF-nTIVMA1GBn8hAemVCBKXy8sUspQ1eIZAxICtYeSUk9DzM8-It9-AAbi0FudCRS8PkcTaZ-8SXnNYRk2-iYKMin_fYUG2kT8LbApmaeb1RjtxXQUF8HbvAu HTTP/1.1" 302 - 0.0724
2013-03-10T22:34:57+00:00 app[web.1]: 24.20.19.205 - - [10/Mar/2013 22:34:57] "GET / HTTP/1.1" 200 6836 0.2166
2013-03-10T22:34:57+00:00 heroku[router]: at=info method=GET path=/ host=toolshed.herokuapp.com fwd="24.20.19.205" dyno=web.1 queue=0 wait=9ms connect=15ms service=235ms status=200 bytes=6836
2013-03-10T22:35:01+00:00 app[web.2]: NoMethodError - undefined method `length' for nil:NilClass:
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:708:in `block (2 levels) in route!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:755:in `catch'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:755:in `process_route'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:758:in `block in process_route'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `block in invoke'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:in `block in perform_action_with_newrelic_trace'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `catch'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:644:in `block in call!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `invoke'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `instance_eval'
2013-03-10T22:35:01+00:00 app[web.2]: /app/app.rb:86:in `block in <top (required)>'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152:in `block in compile!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:724:in `instance_eval'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:706:in `each'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:706:in `route!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:724:in `route_eval'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:843:in `dispatch!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/head.rb:9:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/sinatra.rb:48:in `block in dispatch_with_newrelic'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/sinatra.rb:47:in `dispatch_with_newrelic'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1303:in `synchronize'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in `perform_action_with_newrelic_trace'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:707:in `block in route!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:84:in `block in pre_process'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1272:in `block in call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/commonlogger.rb:20:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:644:in `call!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:629:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/session/abstract/id.rb:190:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/methodoverride.rb:24:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1272:in `call'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/controllers/controller.rb:86:in `start'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/runner.rb:185:in `run_command'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/session/abstract/id.rb:195:in `context'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/runner.rb:151:in `run!'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
2013-03-10T22:35:01+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/bin/thin:6:in `<top (required)>'
2013-03-10T22:35:01+00:00 app[web.2]: 24.20.19.205 - - [10/Mar/2013 22:35:01] "GET /friends_tools.html HTTP/1.1" 500 30 0.1515
2013-03-10T22:35:01+00:00 heroku[router]: at=info method=GET path=/friends_tools.html host=toolshed.herokuapp.com fwd="24.20.19.205" dyno=web.2 queue=0 wait=0ms connect=4ms service=156ms status=500 bytes=30

最佳答案

该问题仅在扩展超过一个测功机时出现,这一事实表明它可能是一个共享状态问题。 IE。用户在 dyno-1 上进行身份验证, session ID 存储在 dyno-1 的内存中。同一用户的下一个请求是 dyno-2 的服务器,它不知道 session 并崩溃了。这纯属猜测,我没有检查过你的代码。

或者,this Sinatra issue New Relic 有类似的错误,建议升级到 New Relic 问题的预发布版本可以解决问题。

关于ruby - 在 Heroku 上增加 dyno 数量后的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15328989/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com