Sha256: 642be05c589e176a46cc09ade1411d4dc88b1fd3c583463f178ce9d12ac1c5a5

Contents?: true

Size: 1.08 KB

Versions: 126

Compression:

Stored size: 1.08 KB

Contents

require 'puppet/util/pidlock'

# This module is responsible for encapsulating the logic for "locking" the
# puppet agent during a catalog run; in other words, keeping track of enough
# state to answer the question "is there a puppet agent currently applying a
# catalog?"
#
# The implementation involves writing a lockfile whose contents are simply the
# PID of the running agent process.  This is considered part of the public
# Puppet API because it used by external tools such as mcollective.
#
# For more information, please see docs on the website.
#  http://links.puppetlabs.com/agent_lockfiles
module Puppet::Agent::Locker
  # 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
    end
  end

  def running?
    lockfile.locked?
  end

  def lockfile_path
    @lockfile_path ||= Puppet[:agent_catalog_run_lockfile]
  end

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

    @lockfile
  end
  private :lockfile


end

Version data entries

126 entries across 126 versions & 3 rubygems

Version Path
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/agent/locker.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/agent/locker.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/agent/locker.rb
puppet-3.8.3 lib/puppet/agent/locker.rb
puppet-3.8.3-x86-mingw32 lib/puppet/agent/locker.rb
puppet-3.8.3-x64-mingw32 lib/puppet/agent/locker.rb
puppet-4.2.2 lib/puppet/agent/locker.rb
puppet-4.2.2-x86-mingw32 lib/puppet/agent/locker.rb
puppet-4.2.2-x64-mingw32 lib/puppet/agent/locker.rb
puppet-retrospec-0.8.0 vendor/gems/puppet-3.7.3/lib/puppet/agent/locker.rb
puppet-3.8.2 lib/puppet/agent/locker.rb
puppet-3.8.2-x86-mingw32 lib/puppet/agent/locker.rb
puppet-3.8.2-x64-mingw32 lib/puppet/agent/locker.rb
puppet-retrospec-0.7.3 vendor/gems/puppet-3.7.3/lib/puppet/agent/locker.rb
puppet-4.2.1 lib/puppet/agent/locker.rb
puppet-4.2.1-x86-mingw32 lib/puppet/agent/locker.rb
puppet-4.2.1-x64-mingw32 lib/puppet/agent/locker.rb
puppet-4.2.0 lib/puppet/agent/locker.rb
puppet-4.2.0-x86-mingw32 lib/puppet/agent/locker.rb
puppet-4.2.0-x64-mingw32 lib/puppet/agent/locker.rb