lib/right_chimp/exec/Executor.rb in right_chimp-1.1.3 vs lib/right_chimp/exec/Executor.rb in right_chimp-2.0
- old
+ new
@@ -3,11 +3,11 @@
#
module Chimp
class Executor
attr_accessor :server, :array, :exec, :inputs, :template, :owner, :group,
- :job_id, :status, :dry_run, :verbose, :quiet, :timeout,
+ :job_id, :job_uuid, :status, :dry_run, :verbose, :quiet, :timeout,
:retry_count, :retry_sleep, :time_start, :time_end, :error
attr_reader :results
STATUS_NONE = :none
@@ -21,10 +21,11 @@
@server = h[:server] || nil
@array = h[:array] || nil
@template = h[:template] || nil
@job_id = h[:job_id] || nil
+ @job_uuid = h[:job_uuid] || nil
@group = h[:group] || nil
@exec = h[:exec] || nil
@inputs = h[:inputs] || nil
@verbose = h[:verbose] || false
@@ -103,10 +104,11 @@
def run_with_retry(&block)
Log.debug "Running job '#{@job_id}' with status '#{@status}'"
@status = STATUS_RUNNING
@time_start = Time.now
+
Log.info self.describe_work_start unless @quiet
#
# The inner level of exception handling here tries to catch anything
# that can be easily retired or failed-- normal exceptions.
@@ -122,11 +124,11 @@
if @owner != nil
@status = STATUS_DONE
@group.job_completed
else
- Log.warn "Ownership of job_id #{job_id} lost. User cancelled operation?"
+ Log.warn "[#{@job_uuid}] Ownership of job_id #{job_id} lost. User cancelled operation?"
end
rescue SystemExit, Interrupt => ex
$stderr.puts "Exiting!"
raise ex
@@ -136,26 +138,26 @@
name = @server['name'] || @server['nickname'] if @server
Log.error self.describe_work_error
if @retry_count > 0
@status = STATUS_RETRYING
- Log.error "Error executing on \"#{name}\". Retrying in #{@retry_sleep} seconds..."
+ Log.error "[#{@job_uuid}] Error executing on \"#{name}\". Retrying in #{@retry_sleep} seconds..."
@retry_count -= 1
sleep @retry_sleep
retry
end
@status = STATUS_ERROR
@error = ex
- Log.error "Error executing on \"#{name}\": #{ex}"
+ Log.error "[#{@job_uuid}] Error executing on \"#{name}\": #{ex}"
ensure
@time_end = Time.now
Log.info self.describe_work_done unless @quiet
end
rescue RuntimeError => ex
- Log.error "Caught RuntimeError: #{ex}. Aborting job."
+ Log.error "[#{@job_uuid}] Caught RuntimeError: #{ex}. Aborting job."
Log.error ex.inspect
Log.error ex.backtrace
@status = STATUS_ERROR
@error = ex
end