Sha256: 49863e200da7fe57bdfad0df46eac3e0273d9b17122e540e74b5daed684d4b42

Contents?: true

Size: 842 Bytes

Versions: 36

Compression:

Stored size: 842 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?
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
puppet-2.6.18 lib/puppet/agent/locker.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
puppet-2.6.17 lib/puppet/agent/locker.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
puppet-2.6.16 lib/puppet/agent/locker.rb
puppet-2.6.15 lib/puppet/agent/locker.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
puppet-2.6.14 lib/puppet/agent/locker.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/agent/locker.rb
puppet-2.6.13 lib/puppet/agent/locker.rb
puppet-2.7.9 lib/puppet/agent/locker.rb
puppet-2.7.8 lib/puppet/agent/locker.rb
puppet-2.7.6 lib/puppet/agent/locker.rb
puppet-2.6.12 lib/puppet/agent/locker.rb