summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2014-01-11 14:08:05 +0100
committerAlex Legler <alex@a3li.li>2014-01-11 14:08:05 +0100
commitfcd973a11b093d8969f51a3b712900e85a645f92 (patch)
tree3b5941e7a354e48284e638d0a6d17e68045d3be5 /lib
parentDisplay cache times (diff)
downloadinfra-status-fcd973a11b093d8969f51a3b712900e85a645f92.tar.gz
infra-status-fcd973a11b093d8969f51a3b712900e85a645f92.tar.bz2
infra-status-fcd973a11b093d8969f51a3b712900e85a645f92.zip
Fix recursion in update logic
Diffstat (limited to 'lib')
-rw-r--r--lib/service_registry.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/service_registry.rb b/lib/service_registry.rb
index 7ac5f85..f21a74a 100644
--- a/lib/service_registry.rb
+++ b/lib/service_registry.rb
@@ -74,6 +74,7 @@ class ServiceRegistry
attr_reader :load_date
def initialize
+ @cache_locked = false
end
def service(name, &block)
@@ -91,15 +92,17 @@ class ServiceRegistry
end
def update!
+ @cache_locked = true
@services = {}
@status_data = JSON.parse(File.read(StatusSource))
load(File.join(File.dirname(__FILE__), '..', 'data', 'services.rb'))
@load_date = DateTime.now
+ @cache_locked = false
end
private
def update?
- if not @load_date.nil? and ((DateTime.now - @load_date) * 60 * 60 * 24).to_i > CACHE_SECONDS
+ if not @load_date.nil? and not @cache_locked and ((DateTime.now - @load_date) * 60 * 60 * 24).to_i > CACHE_SECONDS
update!
end
end