预期的(200)< => Heroku上的实际(403禁止)

时间:2014-04-09 21:55:37

标签: ruby-on-rails heroku

早上好,我在使用Heroku时遇到严重问题。我得到了一个应该可以正常工作的应用程序,但在某些时候它停止发送电子邮件(通过使用sidekiq工作人员处理)。该应用程序在本地运行正常,但在生产时,只要我们尝试发送电子邮件(甚至排队工作人员),它就会崩溃。

我在日志中有几个堆栈跟踪

第一个是最相关的,因为我大部分时间都看到它。

首先:

2014-04-09T19:25:16.043768+00:00 app[web.1]: "Scaling sidekiq to 1"
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/excon-0.25.1/lib/excon/connection.rb:353:in `response'
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/excon-0.25.1/lib/excon/connection.rb:247:in `request'
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/excon-0.25.1/lib/excon/middlewares/expects.rb:6:in `response_call'
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/heroku-api-0.3.13/lib/heroku/api.rb:76:in `request'
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/autoscaler-0.2.1/lib/autoscaler/heroku_scaler.rb:38:in `workers='
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/heroku-api-0.3.13/lib/heroku/api/processes.rb:36:in `post_ps_scale'
2014-04-09T19:25:16.188312+00:00 app[web.1]: Expected(200) <=> Actual(403 Forbidden)
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/autoscaler-0.2.1/lib/autoscaler/sidekiq.rb:17:in `call'
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/middleware/chain.rb:114:in `call'
2014-04-09T19:25:16.188542+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/middleware/chain.rb:114:in `invoke'
2014-04-09T19:25:16.188921+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/worker.rb:68:in `client_push'
2014-04-09T19:25:16.188921+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/client.rb:113:in `process_single'
2014-04-09T19:25:16.188921+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/extensions/generic_proxy.rb:17:in `method_missing'
2014-04-09T19:25:16.188921+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.17/lib/active_record/associations/collection_proxy.rb:91:in `each'
2014-04-09T19:25:16.188921+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/client.rb:41:in `push'

然后:

2014-04-09T20:48:39.399640+00:00 app[web.2]: "Scaling sidekiq to 1"
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/excon-0.25.1/lib/excon/response.rb:36:in `parse'
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/excon-0.25.1/lib/excon/connection.rb:350:in `response'
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/excon-0.25.1/lib/excon/connection.rb:247:in `request'
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/heroku-api-0.3.13/lib/heroku/api/processes.rb:36:in `post_ps_scale'
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/autoscaler-0.2.1/lib/autoscaler/heroku_scaler.rb:38:in `workers='
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/worker.rb:68:in `client_push'
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/autoscaler-0.2.1/lib/autoscaler/sidekiq.rb:17:in `call'
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/middleware/chain.rb:114:in `call'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/middleware/chain.rb:114:in `invoke'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/client.rb:113:in `process_single'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/client.rb:41:in `push'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/sidekiq-2.10.1/lib/sidekiq/extensions/generic_proxy.rb:17:in `method_missing'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/app/models/notification/bid_created.rb:21:in `deliver_email'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/app/models/notification/base.rb:39:in `deliver_email_or_queue_digest'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:417:in `_run__2996144092637045089__create__484298484390863538__callbacks'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:405:in `__run_callback'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:81:in `run_callbacks'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.17/lib/active_record/associations/collection_proxy.rb:91:in `each'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.17/lib/active_record/associations/collection_proxy.rb:91:in `method_missing'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/app/models/notification/base.rb:25:in `block in deliver_notifications_according_to_preferences'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/app/models/notification/base.rb:24:in `map'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/app/models/notification/base.rb:24:in `deliver_notifications_according_to_preferences'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/app/models/notification/base.rb:14:in `deliver'
2014-04-09T20:48:39.401684+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.17/lib/active_record/callbacks.rb:268:in `create'
2014-04-09T20:48:39.401684+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.17/lib/active_record/persistence.rb:348:in `create_or_update'
2014-04-09T20:48:39.401684+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.17/lib/active_record/callbacks.rb:264:in `block in create_or_update'
2014-04-09T20:48:39.401684+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:436:in `_run__2996144092637045089__save__484298484390863538__callbacks'
2014-04-09T20:48:39.401134+00:00 app[web.2]: /app/app/models/bid.rb:59:in `notify_property_managers_of_creation'
2014-04-09T20:48:39.400727+00:00 app[web.2]: undefined method `[]' for nil:NilClass (NoMethodError)
2014-04-09T20:48:39.400727+00:00 app[web.2]: /app/vendor/bundle/ruby/2.0.0/gems/heroku-api-0.3.13/lib/heroku/api.rb:76:in `request'
2014-04-09T20:48:39.400943+00:00 app[web.2]: /app/app/models/notification/base.rb:27:in `block (2 levels) in deliver_notifications_according_to_preferences'

第一个建议和扩展问题,我不知道它为什么会发生,因为做heroku ps正确输出sidekiq worker为1。 另一个我不清楚,我调试了应用程序,不在我的代码中。似乎又与heroku内部库有关。我不知道下一步该尝试什么,任何建议都会受到很大的影响。

编辑:我们暂时解决了这个问题,删除了autoscaler gem并按照http://manuelvanrijn.nl/blog/2012/11/13/sidekiq-on-heroku-with-redistogo-nano/的建议手动配置Sidekiq,但是我真的想保留自动缩放器以减少资源使用。如何仔细检查我的API_KEY和APP env变量是否有权创建新工作人员?改变了自动调节器宝石吗?

非常感谢

0 个答案:

没有答案