-
Notifications
You must be signed in to change notification settings - Fork 5
Troubleshooting Resque
Here's a quick-and-easy way to write Resque debugging information into a custom (and therefore extremely pertinent/quiet) log file:
Resque.logger = Logger.new(Rails.root.join('log', "#{Rails.env}_resque.log"))
Resque.logger.level = Logger::DEBUG
Resque.logger.debug("Useful error message from failing job")
Putting these lines into the beginning of a job's perform method and restarting the app should let you write debugging statements from that method. Here's an example, from a test class that raises an error:
class Lakeshore::TestFailJob < ActiveJob::Base
queue_as :test_fail
def perform
Resque.logger = Logger.new(Rails.root.join('log', "#{Rails.env}_resque.log"))
Resque.logger.level = Logger::DEBUG
Resque.logger.debug("Useful error message from failing job")
raise StandardError
end
end
Arguments are sent to the Resque job as base64-encoded strings. You can decode them to see what the job was trying to run. From the Resque admin page, copy the string from the web page. It will look something like: BAhvOhlDcmVhdGVEZXJpdmF0aXZlc0pvYgY6CEBpZEkiDlNJLTAwMDIyMQY6BkVU
.
From a Ruby console:
require 'base64'
Base64.decode64("BAhvOhlDcmVhdGVEZXJpdmF0aXZlc0pvYgY6CEBpZEkiDlNJLTAwMDIyMQY6BkVU")
You can restart failed jobs to see if they pass. If they do not, a new failure will appear in the failed queue. If it does pass, you can remove the failed job.