Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Merge 25e67ef into fa4febd
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanpalmer committed Nov 23, 2015
2 parents fa4febd + 25e67ef commit 3f9b4ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/scheduler/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ def schedule_next_job(hostname=nil)
redis.zrem Manager.queue_key(hostname), key
return
end

unless klass.respond_to?(:daily) &&
klass.respond_to?(:every)
# job klass exists but no longer extends from the base
redis.zrem Manager.queue_key(hostname), key
return
end

info = schedule_info(klass)
info.prev_run = Time.now.to_i
info.prev_result = "QUEUED"
Expand Down
9 changes: 9 additions & 0 deletions spec/manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def perform
self.class.runs += 1
end
end

class InvalidJob
end
end

let(:manager) { Scheduler::Manager.new($redis) }
Expand Down Expand Up @@ -114,6 +117,12 @@ def perform
expect($redis.zcard(Scheduler::Manager.queue_key)).to eq(0)
end

it 'should nuke invalid jobs' do
$redis.zadd Scheduler::Manager.queue_key, Time.now.to_i - 1000, "Testing::InvalidJob"
manager.tick
expect($redis.zcard(Scheduler::Manager.queue_key)).to eq(0)
end

it 'should recover from crashed manager' do

info = manager.schedule_info(Testing::SuperLongJob)
Expand Down

0 comments on commit 3f9b4ca

Please sign in to comment.