Class: Rufus::TrackingScheduler::JobRunner
- Inherits:
-
Object
- Object
- Rufus::TrackingScheduler::JobRunner
show all
- Defined in:
- lib/rufus-runner/tracking_scheduler/job_runner.rb
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ JobRunner
Returns a new instance of JobRunner.
7
8
9
10
11
12
|
# File 'lib/rufus-runner/tracking_scheduler/job_runner.rb', line 7
def initialize(options)
@name = options.fetch(:name)
@job = options.fetch(:job)
@block = options.fetch(:block)
@scheduler = options.fetch(:scheduler)
end
|
Instance Method Details
#run ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rufus-runner/tracking_scheduler/job_runner.rb', line 14
def run
return if @scheduler.shutting_down?
@job.job_runner = self
start_time = Time.now
log("starting")
begin
run_block
rescue Exception => exception
log("failed with #{exception.class.name} (#{exception.message})")
if defined?(ActiveRecord::ConnectionTimeoutError) && exception.kind_of?(ActiveRecord::ConnectionTimeoutError)
log("connection broken, exiting scheduler")
exit 0
end
else
total_time = Time.now - start_time
log("completed in %.3f s" % total_time)
end
if defined?(ActiveRecord::Base)
ActiveRecord::Base.clear_active_connections!
end
end
|
#shutdown ⇒ Object
38
39
40
|
# File 'lib/rufus-runner/tracking_scheduler/job_runner.rb', line 38
def shutdown
raise NotImplementedError.new
end
|