Module: Puppet::Agent::Locker
- Included in:
- Puppet::Agent
- Defined in:
- lib/puppet/agent/locker.rb
Overview
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.
Instance Method Summary collapse
-
#disable ⇒ Object
Stop the daemon from making any catalog runs.
-
#enable ⇒ Object
Let the daemon run again, freely in the filesystem.
-
#lock ⇒ Object
Yield if we get a lock, else do nothing.
- #lockfile ⇒ Object
- #running? ⇒ Boolean
Instance Method Details
#disable ⇒ Object
Stop the daemon from making any catalog runs.
12 13 14 |
# File 'lib/puppet/agent/locker.rb', line 12 def disable lockfile.lock(:anonymous => true) end |
#enable ⇒ Object
Let the daemon run again, freely in the filesystem.
7 8 9 |
# File 'lib/puppet/agent/locker.rb', line 7 def enable lockfile.unlock(:anonymous => true) end |
#lock ⇒ Object
Yield if we get a lock, else do nothing. Return true/false depending on whether we get the lock.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/puppet/agent/locker.rb', line 18 def lock if lockfile.lock begin yield ensure lockfile.unlock end return true else return false end end |
#lockfile ⇒ Object
31 32 33 34 35 |
# File 'lib/puppet/agent/locker.rb', line 31 def lockfile @lockfile ||= Puppet::Util::Pidlock.new(lockfile_path) @lockfile end |
#running? ⇒ Boolean
37 38 39 |
# File 'lib/puppet/agent/locker.rb', line 37 def running? lockfile.locked? end |