summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/client.rb1
-rwxr-xr-xlib/puppet/daemon.rb38
2 files changed, 25 insertions, 14 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index 495e190f9..0dd5221ed 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -144,6 +144,7 @@ module Puppet
# Start listening for events. We're pretty much just listening for
# timer events here.
def start
+ super
# Create our timer
timer = EventLoop::Timer.new(
:interval => Puppet[:runinterval],
diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb
index 4b9e1f6f0..f8d67db95 100755
--- a/lib/puppet/daemon.rb
+++ b/lib/puppet/daemon.rb
@@ -6,8 +6,11 @@ module Puppet
# A module that handles operations common to all daemons. This is included
# into the Server and Client base classes.
module Daemon
+ Puppet.config.setdefaults(:puppet, :setpidfile => [true,
+ "Whether to store a PID file for the daemon."])
def daemonname
- $0.sub(/.+#{File::SEPARATOR}/,'')
+ #$0.sub(/.+#{File::SEPARATOR}/,'')
+ Puppet.name
end
# The path to the pid file for this server
@@ -22,7 +25,7 @@ module Puppet
exit(0)
end
- setpidfile()
+ #setpidfile()
# Get rid of console logging
Puppet::Log.close(:console)
@@ -36,9 +39,9 @@ module Puppet
Puppet::Log.reopen
rescue => detail
File.open("/tmp/daemonout", "w") { |f|
- f.puts "Could not start %s: %s" % [$0, detail]
+ f.puts "Could not start %s: %s" % [Puppet.name, detail]
}
- Puppet.err "Could not start %s: %s" % [$0, detail]
+ Puppet.err "Could not start %s: %s" % [Puppet.name, detail]
exit(12)
end
end
@@ -205,14 +208,16 @@ module Puppet
def setpidfile
Puppet.config.use(:puppet)
@pidfile = self.pidfile
- if FileTest.exists?(@pidfile)
- Puppet.info "Deleting old pid file"
- begin
- File.unlink(@pidfile)
- rescue Errno::EACCES
- Puppet.err "Could not delete old PID file; cannot create new one"
- return
- end
+ if FileTest.exists?(@pidfile) and not defined? $setpidfile
+ raise Puppet::Error, "A PID file already exists for #{Puppet.name}
+at #{@pidfile}. Not starting."
+ #Puppet.info "Deleting old pid file"
+ #begin
+ # File.unlink(@pidfile)
+ #rescue Errno::EACCES
+ # Puppet.err "Could not delete old PID file; cannot create new one"
+ # return
+ #end
end
#unless FileTest.exists?(Puppet[:rundir])
@@ -220,14 +225,14 @@ module Puppet
# File.chmod(01777, Puppet[:rundir])
#end
- Puppet.info "Setting pidfile to %s" % @pidfile
+ 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
exit(74)
end
- Puppet.info "pid file is %s" % @pidfile
+ $setpidfile = true
end
# Shut down our server
@@ -247,6 +252,11 @@ module Puppet
super
end
+
+ def start
+ setpidfile()
+ super
+ end
end
end