mirror of
https://github.com/cmur2/dyndnsd.git
synced 2024-12-22 10:54:23 +01:00
dyndnsd: allow updater to see if database changed
This commit is contained in:
parent
0cec44893d
commit
0c4c38cc6b
@ -68,6 +68,9 @@ Style/HashTransformValues:
|
|||||||
Style/IdenticalConditionalBranches:
|
Style/IdenticalConditionalBranches:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/IfUnlessModifier:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Style/InverseMethods:
|
Style/InverseMethods:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
@ -79,3 +82,6 @@ Style/RescueModifier:
|
|||||||
|
|
||||||
Style/SymbolArray:
|
Style/SymbolArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/TrailingCommaInArrayLiteral:
|
||||||
|
Enabled: false
|
||||||
|
9
lib/dyndnsd.rb
Executable file → Normal file
9
lib/dyndnsd.rb
Executable file → Normal file
@ -56,9 +56,9 @@ module Dyndnsd
|
|||||||
@db.load
|
@db.load
|
||||||
@db['serial'] ||= 1
|
@db['serial'] ||= 1
|
||||||
@db['hosts'] ||= {}
|
@db['hosts'] ||= {}
|
||||||
|
@updater.update(@db)
|
||||||
if @db.changed?
|
if @db.changed?
|
||||||
@db.save
|
@db.save
|
||||||
@updater.update(@db)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,8 +193,8 @@ module Dyndnsd
|
|||||||
def update_db
|
def update_db
|
||||||
@db['serial'] += 1
|
@db['serial'] += 1
|
||||||
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
||||||
@db.save
|
|
||||||
@updater.update(@db)
|
@updater.update(@db)
|
||||||
|
@db.save
|
||||||
Metriks.meter('updates.committed').mark
|
Metriks.meter('updates.committed').mark
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -313,7 +313,10 @@ module Dyndnsd
|
|||||||
private_class_method def self.setup_rack(config)
|
private_class_method def self.setup_rack(config)
|
||||||
# configure daemon
|
# configure daemon
|
||||||
db = Database.new(config['db'])
|
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)
|
daemon = Daemon.new(config, db, updater)
|
||||||
|
|
||||||
# configure rack
|
# configure rack
|
||||||
|
@ -14,6 +14,9 @@ module Dyndnsd
|
|||||||
# @param db [Dyndnsd::Database]
|
# @param db [Dyndnsd::Database]
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def update(db)
|
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|
|
Helper.span('updater_update') do |span|
|
||||||
span.set_tag('dyndnsd.updater.name', self.class.name&.split('::')&.last || 'None')
|
span.set_tag('dyndnsd.updater.name', self.class.name&.split('::')&.last || 'None')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user