Sha256: a44bc8fd47720f4c231997d4fef6d090759f54ea59b87cf2a63b0133e79c587d

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

module Dyndnsd
  module Updater
    class CommandWithBindZone
      def initialize(domain, config)
        @zone_file = config['zone_file']
        @command = config['command']
        @generator = Generator::Bind.new(domain, config)
      end

      def update(zone)
        Helper.span('updater_update') do |span|
          span.set_tag('dyndnsd.updater.name', self.class.name.split('::').last)

          # write zone file in bind syntax
          File.open(@zone_file, 'w') { |f| f.write(@generator.generate(zone)) }
          # call user-defined command
          pid = fork do
            exec @command
          end

          # detach so children don't become zombies
          Process.detach(pid)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dyndnsd-2.0.0 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-2.0.0.rc2 lib/dyndnsd/updater/command_with_bind_zone.rb
dyndnsd-2.0.0.rc1 lib/dyndnsd/updater/command_with_bind_zone.rb