diff options
| author | mpalmer <mpalmer@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-31 05:57:23 +0000 |
|---|---|---|
| committer | mpalmer <mpalmer@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-31 05:57:23 +0000 |
| commit | 27c1b49bb78729d0bb545f5998d4539c64f14d71 (patch) | |
| tree | d69b64ba8252c5e4727a1ae355fa63d2e92d6b2d /lib/puppet/daemon.rb | |
| parent | 16f7980ef4d65a89007079f15c04744b5bedfc65 (diff) | |
| download | puppet-27c1b49bb78729d0bb545f5998d4539c64f14d71.tar.gz puppet-27c1b49bb78729d0bb545f5998d4539c64f14d71.tar.xz puppet-27c1b49bb78729d0bb545f5998d4539c64f14d71.zip | |
Switch puppet/daemon.rb to use Pidlock
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2003 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/daemon.rb')
| -rwxr-xr-x | lib/puppet/daemon.rb | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index cd356e6cc..90ef42a55 100755 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -238,40 +238,19 @@ module Puppet # Remove the pid file def rmpidfile threadlock(:pidfile) do - if defined? @pidfile and @pidfile and FileTest.exists?(@pidfile) - begin - File.unlink(@pidfile) - rescue => detail - Puppet.err "Could not remove PID file %s: %s" % - [@pidfile, detail] - end - end + Puppet::Util::Pidlock.new(pidfile).unlock or Puppet.err "Could not remove PID file %s" % [pidfile] end end # Create the pid file. def setpidfile return unless Puppet[:setpidfile] + threadlock(:pidfile) do - Puppet.config.use(:puppet) - @pidfile = self.pidfile - if FileTest.exists?(@pidfile) - if defined? $setpidfile - return - else - raise Puppet::Error, "A PID file already exists for #{Puppet.name} - at #{@pidfile}. Not starting." - end - end - - Puppet.info "Creating PID file to %s" % @pidfile - begin - File.open(@pidfile, "w") { |f| f.puts $$ } - rescue => detail - Puppet.err "Could not create PID file: %s" % detail + unless Puppet::Util::Pidlock.new(pidfile).lock + Puppet.err("Could not create PID file: %s" % [pidfile] exit(74) end - $setpidfile = true end end |
