summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-05-17 23:22:44 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-05-18 17:07:17 +1000
commitf4cb8f36dfb2ae05d64ef609d03795537b0720fa (patch)
tree9dd502300c8a1460a204c75219b9f484c76b74bf /lib
parenta18298a0a9a0d465348164c21fc3dd433aeaa7fc (diff)
downloadpuppet-f4cb8f36dfb2ae05d64ef609d03795537b0720fa.tar.gz
puppet-f4cb8f36dfb2ae05d64ef609d03795537b0720fa.tar.xz
puppet-f4cb8f36dfb2ae05d64ef609d03795537b0720fa.zip
Adding some usability bits to puppetqd
There's better logging, and it's a bit more exception-friendly. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/application/puppetqd.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/puppet/application/puppetqd.rb b/lib/puppet/application/puppetqd.rb
index a3a302e17..d5c0c7a45 100644
--- a/lib/puppet/application/puppetqd.rb
+++ b/lib/puppet/application/puppetqd.rb
@@ -3,8 +3,10 @@ require 'puppet/daemon'
require 'puppet/application'
require 'puppet/resource/catalog'
require 'puppet/indirector/catalog/queue'
+require 'puppet/util'
Puppet::Application.new(:puppetqd) do
+ extend Puppet::Util
should_parse_config
attr_accessor :daemon
@@ -12,10 +14,19 @@ Puppet::Application.new(:puppetqd) do
preinit do
@daemon = Puppet::Daemon.new
@daemon.argv = ARGV.dup
+ Puppet::Util::Log.newdestination(:console)
# Do an initial trap, so that cancels don't get a stack trace.
+
+ # This exits with exit code 1
trap(:INT) do
- $stderr.puts "Cancelling startup"
+ $stderr.puts "Caught SIGINT; shutting down"
+ exit(1)
+ end
+
+ # This is a normal shutdown, so code 0
+ trap(:TERM) do
+ $stderr.puts "Caught SIGTERM; shutting down"
exit(0)
end
@@ -31,12 +42,19 @@ Puppet::Application.new(:puppetqd) do
option("--verbose","-v")
command(:main) do
+ Puppet.notice "Starting puppetqd %s" % Puppet.version
Puppet::Resource::Catalog::Queue.subscribe do |catalog|
# Once you have a Puppet::Resource::Catalog instance, calling save() on it should suffice
# to put it through to the database via its active_record indirector (which is determined
# by the terminus_class = :active_record setting above)
- Puppet.notice "Processing queued catalog for %s" % catalog.name
- catalog.save
+ benchmark(:notice, "Processing queued catalog for %s" % catalog.name) do
+ begin
+ catalog.save
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Could not save queued catalog for %s: %s" % [catalog.name, detail]
+ end
+ end
end
Thread.list.each { |thread| thread.join }