diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-20 16:16:14 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-20 16:16:14 +0100 |
commit | 3185e5d746abda1b7f42ecdbd74ec14359fda3bc (patch) | |
tree | e74ee3a587d62fdf68f79093af2202188aed3bc5 /lib/mauve/timer.rb | |
parent | 4ffe222986d4e3565a1f189325d77b33f90dfa15 (diff) | |
parent | d3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff) |
merge
Diffstat (limited to 'lib/mauve/timer.rb')
-rw-r--r-- | lib/mauve/timer.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/mauve/timer.rb b/lib/mauve/timer.rb index f6ada88..91dea18 100644 --- a/lib/mauve/timer.rb +++ b/lib/mauve/timer.rb @@ -13,12 +13,6 @@ module Mauve attr_accessor :sleep_interval, :last_run_at - def initialize - super - @initial_sleep = 300 - @initial_sleep_threshold = 300 - end - def main_loop # # Get the next alert. @@ -51,22 +45,27 @@ module Mauve # # Sleep indefinitely # - logger.info("Nothing to notify about -- snoozing indefinitely.") + logger.info("Nothing to notify about -- snoozing for a while.") + sleep_loops = 600 else # # La la la nothing to do. # logger.info("Next to notify: #{next_to_notify} -- snoozing until #{next_to_notify.due_at}") + sleep_loops = ((next_to_notify.due_at - MauveTime.now).to_f / 0.1).round.to_i end + sleep_loops = 1 if sleep_loops.nil? or sleep_loops < 1 + # # Ah-ha! Sleep with a break clause. # - while next_to_notify.nil? or MauveTime.now <= next_to_notify.due_at + sleep_loops.times do # # Start again if the situation has changed. # break if self.should_stop? + # # This is a rate-limiting step for alerts. # |