From 9c7ce90ac627adb7952a61f5125bcea62215283d Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 12 Nov 2012 22:37:47 +0000 Subject: Wrap all the processing of a job in an exception catcher. --- worker/worker | 61 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/worker/worker b/worker/worker index 95fb81d..386600a 100755 --- a/worker/worker +++ b/worker/worker @@ -118,41 +118,38 @@ class Custodian # def process_single_job - job = @queue.reserve() - puts "Job acquired: #{Time.new.inspect}" if ( ENV['VERBOSE'] ) - - - # - # Parse the JSON of the job body. - # - json = job.body - hash = JSON.parse( json ) - hash['verbose'] = 1 if ( ENV['VERBOSE'] ) - - - # - # Output the details. - # - if ( ENV['VERBOSE'] ) - puts "JOB: #{job.id}" - puts "Type of test is #{hash['test_type']}" - hash.keys.each do |key| - puts "\t#{key} => #{hash[key]}" + begin + job = @queue.reserve() + puts "Job acquired: #{Time.new.inspect}" if ( ENV['VERBOSE'] ) + + + # + # Parse the JSON of the job body. + # + json = job.body + hash = JSON.parse( json ) + hash['verbose'] = 1 if ( ENV['VERBOSE'] ) + + + # + # Output the details. + # + if ( ENV['VERBOSE'] ) + puts "JOB: #{job.id}" + puts "Type of test is #{hash['test_type']}" + hash.keys.each do |key| + puts "\t#{key} => #{hash[key]}" + end end - end - # - # Given the test-type of "YYY" we'll call the method "YYY_test", which - # we assume comes from one of the files beneath ./tests/ - # - test = hash['test_type'] - method = "#{test}_test".to_sym + # + # Given the test-type of "YYY" we'll call the method "YYY_test", which + # we assume comes from one of the files beneath ./tests/ + # + test = hash['test_type'] + method = "#{test}_test".to_sym - # - # If it succeeds. - # - begin success = false count = 0 @@ -178,7 +175,7 @@ class Custodian alert.raise() end rescue => ex - puts "Exception: #{ex}" + puts "Exception raised processing job: #{ex}" ensure # # Delete the job - either we received an error, in which case -- cgit v1.2.1