summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-05-17 23:16:22 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-05-18 17:07:17 +1000
commit2771918b9eef9ed26e59688c17c64e86de1b9983 (patch)
tree1b973d714e42fe41e5b20e942c1c3848886c826e
parent07ff4be92a1d46fe0f6ec3de3c33b5a3b99be755 (diff)
downloadpuppet-2771918b9eef9ed26e59688c17c64e86de1b9983.tar.gz
puppet-2771918b9eef9ed26e59688c17c64e86de1b9983.tar.xz
puppet-2771918b9eef9ed26e59688c17c64e86de1b9983.zip
Relying on threads rather than sleeping for puppetqd
We previously manually slept, but this uses the queue client to handle keeping the process running, by just joining all running threads. Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/application/puppetqd.rb6
-rwxr-xr-xspec/unit/application/puppetqd.rb5
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/puppet/application/puppetqd.rb b/lib/puppet/application/puppetqd.rb
index 05bb21fe9..a3a302e17 100644
--- a/lib/puppet/application/puppetqd.rb
+++ b/lib/puppet/application/puppetqd.rb
@@ -39,7 +39,7 @@ Puppet::Application.new(:puppetqd) do
catalog.save
end
- sleep_forever()
+ Thread.list.each { |thread| thread.join }
end
# Handle the logging settings.
@@ -69,8 +69,4 @@ Puppet::Application.new(:puppetqd) do
daemon.daemonize if Puppet[:daemonize]
end
-
- def sleep_forever
- while true do sleep 1000 end
- end
end
diff --git a/spec/unit/application/puppetqd.rb b/spec/unit/application/puppetqd.rb
index 198043efc..0b949385a 100755
--- a/spec/unit/application/puppetqd.rb
+++ b/spec/unit/application/puppetqd.rb
@@ -161,6 +161,7 @@ describe "puppetqd" do
before :each do
@puppetqd.stubs(:sleep_forever)
Puppet::Resource::Catalog::Queue.stubs(:subscribe)
+ Thread.list.each { |t| t.stubs(:join) }
end
it "should subscribe to the queue" do
@@ -177,8 +178,8 @@ describe "puppetqd" do
@puppetqd.main
end
- it "should loop and sleep forever" do
- @puppetqd.expects(:sleep_forever)
+ it "should join all of the running threads" do
+ Thread.list.each { |t| t.expects(:join) }
@puppetqd.main
end
end