mirror of
https://github.com/plashchynski/crono.git
synced 2026-07-11 07:12:50 +02:00
Clean up
This commit is contained in:
+2
-2
@@ -62,7 +62,7 @@ module Crono
|
|||||||
logger.info 'Jobs:'
|
logger.info 'Jobs:'
|
||||||
Crono.scheduler.jobs.each do |job|
|
Crono.scheduler.jobs.each do |job|
|
||||||
logger.info "'#{job.performer}' with rule '#{job.period.description}'"\
|
logger.info "'#{job.performer}' with rule '#{job.period.description}'"\
|
||||||
"next time will perform at #{job.next}"
|
" next time will perform at #{job.next}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ module Crono
|
|||||||
end
|
end
|
||||||
|
|
||||||
def start_working_loop
|
def start_working_loop
|
||||||
while true
|
loop do
|
||||||
next_time, jobs = Crono.scheduler.next_jobs
|
next_time, jobs = Crono.scheduler.next_jobs
|
||||||
sleep(next_time - Time.now)
|
sleep(next_time - Time.now)
|
||||||
jobs.each(&:perform)
|
jobs.each(&:perform)
|
||||||
|
|||||||
+1
-3
@@ -60,9 +60,7 @@ module Crono
|
|||||||
end
|
end
|
||||||
|
|
||||||
def perform_job
|
def perform_job
|
||||||
performer_instance = performer.new
|
performer.new.perform
|
||||||
performer_instance.instance_variable_set(:@_crono_job, self)
|
|
||||||
performer_instance.perform
|
|
||||||
finished_time_sec = format('%.2f', Time.now - last_performed_at)
|
finished_time_sec = format('%.2f', Time.now - last_performed_at)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
handle_job_fail(e, finished_time_sec)
|
handle_job_fail(e, finished_time_sec)
|
||||||
|
|||||||
@@ -32,23 +32,10 @@ describe Crono::Job do
|
|||||||
expect(saved_log).to include 'Some error'
|
expect(saved_log).to include 'Some error'
|
||||||
end
|
end
|
||||||
|
|
||||||
xit 'should set Job#healthy to true if perform ok' do
|
|
||||||
class TestJob
|
|
||||||
def perform
|
|
||||||
@_crono_job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
job.perform.join
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should set Job#healthy to false if perform with error' do
|
it 'should set Job#healthy to false if perform with error' do
|
||||||
failing_job.perform.join
|
failing_job.perform.join
|
||||||
expect(failing_job.healthy).to be false
|
expect(failing_job.healthy).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
xit 'should set @_crono_job variable to instance' do
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#description' do
|
describe '#description' do
|
||||||
|
|||||||
Reference in New Issue
Block a user