summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-04-14 12:58:35 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-04-22 14:39:39 +1000
commit8a67a5c4e059398193b94a06df3f1ac6cc6f095b (patch)
tree3e46ff78cb3e6ff890c357a304c0adb492dfa5dc
parentfcd1390dd95054fdb529481c4603860b9d53be68 (diff)
downloadpuppet-8a67a5c4e059398193b94a06df3f1ac6cc6f095b.tar.gz
puppet-8a67a5c4e059398193b94a06df3f1ac6cc6f095b.tar.xz
puppet-8a67a5c4e059398193b94a06df3f1ac6cc6f095b.zip
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 <luke@madstop.com>
-rwxr-xr-x[-rw-r--r--]bin/puppetqd0
-rw-r--r--lib/puppet/application/puppetqd.rb18
2 files changed, 17 insertions, 1 deletions
diff --git a/bin/puppetqd b/bin/puppetqd
index 14a15b519..14a15b519 100644..100755
--- a/bin/puppetqd
+++ b/bin/puppetqd
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