summaryrefslogtreecommitdiffstats
path: root/lib/puppet/client
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-07-05 17:17:39 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-07-05 17:17:39 +0000
commiteff8d6ef0312b7f26e35b103e0dff9b148f54bd5 (patch)
tree62055027780d2f6f8a514f19553ecf8cd91ab250 /lib/puppet/client
parent6b281eda564c4108f1955deb724e8beebb1e39cb (diff)
downloadpuppet-eff8d6ef0312b7f26e35b103e0dff9b148f54bd5.tar.gz
puppet-eff8d6ef0312b7f26e35b103e0dff9b148f54bd5.tar.xz
puppet-eff8d6ef0312b7f26e35b103e0dff9b148f54bd5.zip
Accepting the patch from #190.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1368 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/client')
-rw-r--r--lib/puppet/client/master.rb33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb
index 0a3419ea4..1c4c57c9c 100644
--- a/lib/puppet/client/master.rb
+++ b/lib/puppet/client/master.rb
@@ -352,15 +352,19 @@ class Puppet::Client::MasterClient < Puppet::Client
end
def locked?
+ return(FileTest.exists? Puppet[:puppetdlockfile])
+ end
+
+ def lockpid
if FileTest.exists? Puppet[:puppetdlockfile]
text = File.read(Puppet[:puppetdlockfile]).chomp
if text =~ /\d+/
- return text
+ return text.to_i
else
- return true
+ return 0
end
else
- return false
+ return 0
end
end
@@ -392,11 +396,26 @@ class Puppet::Client::MasterClient < Puppet::Client
# The code that actually runs the configuration.
def run(tags = nil, ignoreschedules = false)
- if pid = locked?
- t = ""
- if pid != true
- Puppet.notice "Locked by process %s" % pid
+ # Check if the lock is stale, so we can clear it
+ if locked?
+ pid = lockpid
+
+ if pid != 0
+ begin
+ Process.kill(0, pid)
+ rescue Errno::ESRCH
+ # No process with the given PID exists; stale lockfile
+ File.unlink(Puppet[:puppetdlockfile])
+ Puppet.notice("Stale lockfile %s left by process %i; removing" %
+ [Puppet[:puppetdlockfile], pid])
+ lockpid = false
+ else
+ Puppet.notice "Locked by process %s" % pid
+ end
end
+ end
+
+ if locked?
Puppet.notice "Lock file %s exists; skipping configuration run" %
Puppet[:puppetdlockfile]
else