I'm using Rails and Rollbar to track errors and Resque to handle delayed tasks. One of my workers is failing with below error in the 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'
But it would be really helpful to see more robust information about the failure. Eg what were the parameters. Usually I use Rollbar for this type of thing, but it doesn't seem to be logging this error for some reason.
How would I go about fixing this bug? Because I don't really know what's triggering it? (my worker is basically looping through a whole bunch of API calls with different users, and I don't know which one is failing)
You can create a custom logger, and use it to record useful information to trace your problem. In your worker, add debug statements that dump out variable contents, etc.
my_log = Logger.new("log/worker.log")
def do_stuff
my_log.info "#do_stuff"
end
Another option is to put a breakpoint in your code. You'll get an interactive shell that you can use to fiddle around.
debugger
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.