suppress annoying resque errors; add a task to clear Resque failures
This commit is contained in:
parent
d8c6dc0d79
commit
67432bfaf4
3 changed files with 30 additions and 4 deletions
|
|
@ -5,5 +5,22 @@
|
|||
module Jobs
|
||||
class Base
|
||||
Dir["#{Rails.root}/app/models/jobs/mail/*.rb"].each {|file| require file }
|
||||
|
||||
#TODO these should be subclassed real exceptions
|
||||
DUMB_ERROR_MESSAGES = [
|
||||
"Contact required unless request",
|
||||
"Relayable object, but no parent object found" ]
|
||||
|
||||
def self.suppress_annoying_errors(&block)
|
||||
begin
|
||||
yield
|
||||
rescue Exception => e
|
||||
if DUMB_ERROR_MESSAGES.include?(e.message)
|
||||
Rails.logger.error(e.message)
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -9,10 +9,12 @@ module Jobs
|
|||
@queue = :receive_salmon
|
||||
|
||||
def self.perform(user_id, xml)
|
||||
suppress_annoying_errors do
|
||||
user = User.find(user_id)
|
||||
zord = Postzord::Receiver::Private.new(user, :salmon_xml => xml)
|
||||
zord.perform!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,3 +7,10 @@ end
|
|||
|
||||
desc "Alias for resque:work (To run workers on Heroku)"
|
||||
task "jobs:work" => "resque:work"
|
||||
|
||||
desc 'clear your failure queue in resque. good for crons.'
|
||||
task 'resque:clear_failed' => [:environment]do
|
||||
puts "clearing resque failures"
|
||||
Resque::Failure.clear
|
||||
puts "complete!"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue