diff options
| author | Steve Kemp <steve@steve.org.uk> | 2012-11-12 22:37:47 +0000 | 
|---|---|---|
| committer | Steve Kemp <steve@steve.org.uk> | 2012-11-12 22:37:47 +0000 | 
| commit | 9c7ce90ac627adb7952a61f5125bcea62215283d (patch) | |
| tree | ea4bd49c2ec0096c31134e80deb7f83c0f755a0a /worker | |
| parent | f0e4f85733c447d72913e0ceca19d5f783c5f01f (diff) | |
  Wrap all the processing of a job in an exception catcher.
Diffstat (limited to 'worker')
| -rwxr-xr-x | worker/worker | 61 | 
1 files 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 | 
