diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-26 22:47:51 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-26 22:47:51 +0000 |
| commit | 0411f74bc139ddb8147f9aa82d83700dc576939a (patch) | |
| tree | e5d7c087ea84f93b1e366d432760b6b49c971a14 | |
| parent | 31c17e47607bdebf8e2591a98e9fd6f862d3852a (diff) | |
| download | puppet-0411f74bc139ddb8147f9aa82d83700dc576939a.tar.gz puppet-0411f74bc139ddb8147f9aa82d83700dc576939a.tar.xz puppet-0411f74bc139ddb8147f9aa82d83700dc576939a.zip | |
Fixing some more small problems in puppetrun
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1313 980ebf18-57e1-0310-9a29-db15c13687c0
| -rwxr-xr-x | bin/puppetrun | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bin/puppetrun b/bin/puppetrun index 96f016f89..6ff56e98a 100755 --- a/bin/puppetrun +++ b/bin/puppetrun @@ -322,6 +322,8 @@ failures = [] # Now do the actual work go = true while go + # If we don't have enough children in process and we still have hosts left to + # do, then do the next host. if children.length < options[:parallel] and ! todo.empty? host = todo.shift pid = fork do @@ -330,7 +332,7 @@ while go unless $? == 0 $stderr.puts "Could not contact %s" % host - exit(1) + exit(4) end client = Puppet::Client::Runner.new( :Server => host, @@ -342,15 +344,19 @@ while go client.run(tags, options[:ignoreschedules], options[:foreground]) rescue => detail $stderr.puts "Host %s failed: %s" % [host, detail] - next + exit(2) end end children[pid] = host else + # Else, see if we can reap a process. begin pid = Process.wait if host = children[pid] + # Remove our host from the list of children, so the parallelization + # continues working. + children.delete(pid) if $?.exitstatus != 0 failures << host end @@ -360,7 +366,8 @@ while go [pid, $?.exitstatus] end rescue Errno::ECHILD - # There are no children left, so just exit. + # There are no children left, so just exit unless there are still + # children left to do. next unless todo.empty? if failures.empty? @@ -368,7 +375,7 @@ while go exit(0) else puts "Failed: %s" % failures.join(", ") - exit(2) + exit(3) end end end |
