lib/resque/scheduler.rb in sskirby-resque-scheduler-1.10.13 vs lib/resque/scheduler.rb in sskirby-resque-scheduler-1.10.14
- old
+ new
@@ -1,6 +1,7 @@
require 'rufus/scheduler'
+require 'airbrake'
require 'thwait'
module Resque
class Scheduler
@@ -15,10 +16,13 @@
# If set, produces no output
attr_accessor :mute
# If set, will try to update the schulde in the loop
attr_accessor :dynamic
+
+ # If set, will tell rufus to use the airbrake exception handler
+ attr_accessor :airbrake
# the Rufus::Scheduler jobs that are scheduled
def scheduled_jobs
@@scheduled_jobs
end
@@ -164,9 +168,17 @@
end
end
def rufus_scheduler
@rufus_scheduler ||= Rufus::Scheduler.start_new
+ if self.airbrake
+ def @rufus_scheduler.handle_exception(job, exception)
+ puts "Exception caught, notifying Airbrake"
+ id = Airbrake.notify(exception)
+ puts "Airbrake id: #{id}"
+ end
+ end
+ @rufus_scheduler
end
# Stops old rufus scheduler and creates a new one. Returns the new
# rufus scheduler
def clear_schedule!