diff --git a/.rubocop.yml b/.rubocop.yml index 45bc712..4e23acd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -68,6 +68,9 @@ Style/HashTransformValues: Style/IdenticalConditionalBranches: Enabled: false +Style/IfUnlessModifier: + Enabled: false + Style/InverseMethods: Enabled: false @@ -79,3 +82,6 @@ Style/RescueModifier: Style/SymbolArray: Enabled: false + +Style/TrailingCommaInArrayLiteral: + Enabled: false diff --git a/lib/dyndnsd.rb b/lib/dyndnsd.rb old mode 100755 new mode 100644 index 7d9c1cf..38919ce --- a/lib/dyndnsd.rb +++ b/lib/dyndnsd.rb @@ -56,9 +56,9 @@ module Dyndnsd @db.load @db['serial'] ||= 1 @db['hosts'] ||= {} + @updater.update(@db) if @db.changed? @db.save - @updater.update(@db) end end @@ -193,8 +193,8 @@ module Dyndnsd def update_db @db['serial'] += 1 Dyndnsd.logger.info "Committing update ##{@db['serial']}" - @db.save @updater.update(@db) + @db.save Metriks.meter('updates.committed').mark end @@ -313,7 +313,10 @@ module Dyndnsd private_class_method def self.setup_rack(config) # configure daemon db = Database.new(config['db']) - updater = Updater::CommandWithBindZone.new(config['domain'], config.dig('updater', 'params')) if config.dig('updater', 'name') == 'command_with_bind_zone' + case config.dig('updater', 'name') + when 'command_with_bind_zone' + updater = Updater::CommandWithBindZone.new(config['domain'], config.dig('updater', 'params')) + end daemon = Daemon.new(config, db, updater) # configure rack diff --git a/lib/dyndnsd/updater/command_with_bind_zone.rb b/lib/dyndnsd/updater/command_with_bind_zone.rb index 4474b2d..0419216 100644 --- a/lib/dyndnsd/updater/command_with_bind_zone.rb +++ b/lib/dyndnsd/updater/command_with_bind_zone.rb @@ -14,6 +14,9 @@ module Dyndnsd # @param db [Dyndnsd::Database] # @return [void] def update(db) + # do not regenerate zone file (assumed to be persistent) if DB did not change + return if !db.changed? + Helper.span('updater_update') do |span| span.set_tag('dyndnsd.updater.name', self.class.name&.split('::')&.last || 'None')