diff options
author | 2014-01-11 14:08:05 +0100 | |
---|---|---|
committer | 2014-01-11 14:08:05 +0100 | |
commit | fcd973a11b093d8969f51a3b712900e85a645f92 (patch) | |
tree | 3b5941e7a354e48284e638d0a6d17e68045d3be5 /lib | |
parent | Display cache times (diff) | |
download | infra-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.rb | 5 |
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 |