Rails:查找Resque工作程序中发生的错误。没有日志滚动条

时间:2015-10-22 23:11:42

标签: ruby-on-rails resque

我正在使用Rails和Rollbar来跟踪错误,并使用Resque来处理延迟的任务。我的一名工作人员在resque GUI中出现以下错误失败:

Net::ReadTimeout
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_line'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http/response.rb:28:in `read_new'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1412:in `block in transport_request'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1409:in `catch'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1409:in `transport_request'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1382:in `request'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1283:in `request_get'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:479:in `block in get_response'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:852:in `start'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:582:in `start'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:477:in `get_response'
/app/app/services/get_json.rb:4:in `call'
/app/app/models/imdb.rb:9:in `data'
/app/app/models/customer.rb:92:in `imdb_data'
/app/app/models/customer.rb:60:in `get_external_data'
/app/app/models/customer.rb:13:in `scan'
/app/app/models/shop.rb:110:in `block in bulk_scan'
/app/app/models/shop.rb:101:in `each'
/app/app/models/shop.rb:101:in `bulk_scan'
/app/app/workers/bulk_scanner.rb:9:in `perform'

但是看到有关失败的更有力的信息真的很有帮助。例如。什么是参数。通常我会将Rollbar用于此类事情,但由于某种原因它似乎没有记录此错误。

我如何修复此错误?因为我真的不知道是什么触发了它? (我的工作人员基本上是通过不同用户的一大堆API调用循环,我不知道哪一个失败了)

1 个答案:

答案 0 :(得分:0)

您可以创建自定义记录器,并使用它记录有用信息以跟踪问题。在您的worker中,添加转储可变内容等的调试语句

my_log = Logger.new("log/worker.log")

def do_stuff
  my_log.info "#do_stuff"
end

另一个选择是在代码中放置断点。您将获得一个可用于摆弄的交互式shell。

debugger