Sha256: 2621ac6b312650f12d2490bbbe2cb271d177b3f4621eae954aba3bd469ba6bce

Contents?: true

Size: 935 Bytes

Versions: 9

Compression:

Stored size: 935 Bytes

Contents

require 'puppet/util/pidlock'

# Break out the code related to locking the agent.  This module is just
# included into the agent, but having it here makes it easier to test.
module Puppet::Agent::Locker
  # Let the daemon run again, freely in the filesystem.
  def enable
    lockfile.unlock(:anonymous => true)
  end

  # Stop the daemon from making any catalog runs.
  def disable
    lockfile.lock(:anonymous => true)
  end

  # Yield if we get a lock, else do nothing.  Return
  # true/false depending on whether we get the lock.
  def lock
    if lockfile.lock
      begin
        yield
      ensure
        lockfile.unlock
      end
      return true
    else
      return false
    end
  end

  def lockfile
    @lockfile ||= Puppet::Util::Pidlock.new(lockfile_path)

    @lockfile
  end

  def running?
    lockfile.locked? and !lockfile.anonymous?
  end

  def disabled?
    lockfile.locked? and lockfile.anonymous?
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/agent/locker.rb
puppet-2.7.19 lib/puppet/agent/locker.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/agent/locker.rb
puppet-2.7.18 lib/puppet/agent/locker.rb
puppet-2.7.17 lib/puppet/agent/locker.rb
puppet-2.7.16 lib/puppet/agent/locker.rb
puppet-2.7.14 lib/puppet/agent/locker.rb
puppet-2.7.13 lib/puppet/agent/locker.rb
puppet-2.7.12 lib/puppet/agent/locker.rb