From dad596e6c5e241607eee92e54890b53affeba02b Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 16 Oct 2006 03:54:18 +0000 Subject: Fixing #291 -- the problem was that instead of throwing an error on a missing server, puppet was just exiting. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1785 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet.rb | 12 ++++++------ lib/puppet/client/master.rb | 4 ++-- lib/puppet/networkclient.rb | 19 ++++++++++--------- lib/puppet/util.rb | 3 +-- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/puppet.rb b/lib/puppet.rb index 71c7743a7..7d21e8c3d 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -289,12 +289,12 @@ module Puppet # waiting for someone, somewhere, to generate events of some kind. def self.start(block = true) # Starting everything in its own thread, fwiw - defined? @services and @services.each do |svc| + defined? @services and @services.dup.each do |svc| newthread do begin svc.start rescue => detail - if Puppet[:debug] + if Puppet[:trace] puts detail.backtrace end @services.delete svc @@ -303,15 +303,15 @@ module Puppet end end + # We need to give the services a chance to register their timers before + # we try to start monitoring them. + sleep 0.5 + unless @services.length > 0 Puppet.notice "No remaining services; exiting" exit(1) end - # We need to give the services a chance to register their timers before - # we try to start monitoring them. - sleep 0.5 - if defined? @timers and ! @timers.empty? @timers.each do |timer| EventLoop.current.monitor_timer timer diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb index 0763cdfe1..97d224065 100644 --- a/lib/puppet/client/master.rb +++ b/lib/puppet/client/master.rb @@ -168,8 +168,8 @@ class Puppet::Client::MasterClient < Puppet::Client Puppet::Type.allclear end - # Disable running the configuration. This can be used from the command line, but - # is also used to make sure only one client is running at a time. + # Disable running the configuration. This can be used from the command + # line, but is also used to make sure only one client is running at a time. def disable(running = false) threadlock(:puppetd) do text = nil diff --git a/lib/puppet/networkclient.rb b/lib/puppet/networkclient.rb index f093292f2..6284416e3 100644 --- a/lib/puppet/networkclient.rb +++ b/lib/puppet/networkclient.rb @@ -23,8 +23,8 @@ rescue LoadError => detail end module Puppet - class NetworkClientError < RuntimeError; end - class ClientError < RuntimeError; end + class NetworkClientError < Puppet::Error; end + class ClientError < Puppet::Error; end #--------------------------------------------------------------- if $noclientnetworking Puppet.err "Could not load client network libs: %s" % $noclientnetworking @@ -80,16 +80,17 @@ module Puppet [@host, @port] raise NetworkClientError, msg rescue SocketError => detail - Puppet.err "Could not find server %s" % @puppetserver - exit(12) + error = NetworkClientError.new( + "Could not find server %s" % @puppetserver + ) + error.set_backtrace detail.backtrace + raise error rescue => detail Puppet.err "Could not call %s.%s: %s" % [namespace, method, detail.inspect] - #raise NetworkClientError.new(detail.to_s) - if Puppet[:trace] - puts detail.backtrace - end - raise + error = NetworkClientError.new(detail.to_s) + error.set_backtrace detail.backtrace + raise error end } } diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 74a01de4f..b4e8eb253 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -294,8 +294,7 @@ module Util end unless level - puts caller.join("\n") - raise Puppet::DevError, "Failed to provide level" + raise Puppet::DevError, "Failed to provide level to :benchmark" end unless object.respond_to? level -- cgit