From 2771918b9eef9ed26e59688c17c64e86de1b9983 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sun, 17 May 2009 23:16:22 -0500 Subject: 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 --- lib/puppet/application/puppetqd.rb | 6 +----- spec/unit/application/puppetqd.rb | 5 +++-- 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 -- cgit