Module: Puppet::Agent::Locker
- Included in:
- Puppet::Agent
- Defined in:
- lib/vendor/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.
- #disabled? ⇒ Boolean
-
#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.
13 14 15 16 |
# File 'lib/vendor/puppet/agent/locker.rb', line 13 def disable Puppet.notice "Disabling Puppet." lockfile.lock(:anonymous => true) end |
#disabled? ⇒ Boolean
43 44 45 |
# File 'lib/vendor/puppet/agent/locker.rb', line 43 def disabled? lockfile.locked? and lockfile.anonymous? end |
#enable ⇒ Object
Let the daemon run again, freely in the filesystem.
7 8 9 10 |
# File 'lib/vendor/puppet/agent/locker.rb', line 7 def enable Puppet.notice "Enabling Puppet." 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.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vendor/puppet/agent/locker.rb', line 20 def lock if lockfile.lock begin yield ensure lockfile.unlock end return true else return false end end |
#lockfile ⇒ Object
33 34 35 36 37 |
# File 'lib/vendor/puppet/agent/locker.rb', line 33 def lockfile @lockfile ||= Puppet::Util::Pidlock.new(lockfile_path) @lockfile end |
#running? ⇒ Boolean
39 40 41 |
# File 'lib/vendor/puppet/agent/locker.rb', line 39 def running? lockfile.locked? and !lockfile.anonymous? end |