From cc89c8f0deaffa810fb7dc50ef61e48f0948be6d Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Tue, 13 Nov 2012 13:13:39 +0000 Subject: Misc. comment update. --- worker/worker | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'worker') diff --git a/worker/worker b/worker/worker index bc0d65e..241895d 100755 --- a/worker/worker +++ b/worker/worker @@ -141,6 +141,9 @@ class Custodian # Flush the queue. # def flush_queue! + + puts "Flushing queue" if ( ENV['VERBOSE'] ) + while( true ) begin job = @queue.reserve(1) @@ -174,7 +177,8 @@ class Custodian begin job = @queue.reserve() - puts "Job acquired: #{Time.new.inspect}" if ( ENV['VERBOSE'] ) + + puts "Job acquired: #{Time.new.inspect} - Job ID : #{job.id}" if ( ENV['VERBOSE'] ) # @@ -189,8 +193,7 @@ class Custodian # Output the details. # if ( ENV['VERBOSE'] ) - puts "JOB: #{job.id}" - puts "Type of test is #{hash['test_type']}" + puts "Job body contains the following keys & values:" hash.keys.each do |key| puts "\t#{key} => #{hash[key]}" end @@ -214,25 +217,24 @@ class Custodian # - # Convert the test-type to a className + # Convert the test-type to a class name, to do the protocol test. # - # Given a test-type "foo" we'll attempt to instantiate a class - # called FOOTest. + # Given a test-type "foo" we'll attempt to instantiate a class called FOOTest. # test = hash['test_type'] clazz = test.upcase clazz = "#{clazz}Test" + # # Create the test object. # obj = eval(clazz).new( hash ) - # - # Ensure that the object we load implements the methods - # we expect + # Ensure that the object we load implements the two methods + # we expect. # if ( ( ! obj.respond_to?( "error") ) || ( ! obj.respond_to?( "run_test" ) ) ) @@ -259,18 +261,22 @@ class Custodian # if ( ! success ) + # # Raise the alert, passing the error message. + # alert.raise( obj.error() ) end + rescue => ex puts "Exception raised processing job: #{ex}" + ensure # # Delete the job - either we received an error, in which case # we should remove it to avoid picking it up again, or we handled # it successfully so it should be removed. # - job.delete + job.delete if ( job ) end end end @@ -305,7 +311,7 @@ if __FILE__ == $0 then when "--repeat": ENV["REPEAT"] = arg when "--server": - ENV["SERVER"] = arg + $SERVER = arg when "--single": ENV["SINGLE"] = "1" end @@ -340,4 +346,5 @@ if __FILE__ == $0 then # Otherwise loop indefinitely # worker.run! + end -- cgit v1.2.1