From 8a67a5c4e059398193b94a06df3f1ac6cc6f095b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 14 Apr 2009 12:58:35 -0500 Subject: Adding daemonization to puppetqd This will need to be modified on the merge into 0.25, because the daemon module becomes a class, but that should be easy enough. Signed-off-by: Luke Kanies --- bin/puppetqd | 0 lib/puppet/application/puppetqd.rb | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) mode change 100644 => 100755 bin/puppetqd diff --git a/bin/puppetqd b/bin/puppetqd old mode 100644 new mode 100755 diff --git a/lib/puppet/application/puppetqd.rb b/lib/puppet/application/puppetqd.rb index 995668bec..e65ce75dc 100644 --- a/lib/puppet/application/puppetqd.rb +++ b/lib/puppet/application/puppetqd.rb @@ -1,4 +1,5 @@ require 'puppet' +require 'puppet/daemon' require 'puppet/application' require 'puppet/node/catalog' require 'puppet/indirector/catalog/queue' @@ -30,7 +31,18 @@ class Puppet::Util::Settings::CElement end end +class Puppet::Util::Settings::CBoolean + def optparse_args + if short + ["--[no-]#{name}", "-#{short}", desc, :NONE ] + else + ["--[no-]#{name}", desc, :NONE] + end + end +end + Puppet::Application.new(:puppetqd) do + extend Puppet::Daemon should_parse_config @@ -59,8 +71,12 @@ Puppet::Application.new(:puppetqd) do # Once you have a Puppet::Node::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 end + daemonize if Puppet[:daemonize] + + while true do sleep 1000 end end # This is the main application entry point. @@ -70,7 +86,7 @@ Puppet::Application.new(:puppetqd) do def run run_preinit parse_options - Puppet.settings.parse(Puppet[:config]) if should_parse_config? + Puppet.settings.parse(Puppet[:config]) if should_parse_config? and File.exist?(Puppet[:config]) run_setup run_command end -- cgit