end
# Wait the thread (returns a Process::Status)
- exit_status = j_done[:wait_thr].value
+ exit_status = j_done[:wait_thr].value.exitstatus
jobrecord = Job.find_by_uuid(job_done.uuid)
- if exit_status != 75 and jobrecord.started_at
- # Clean up state fields in case crunch-job exited without
- # putting the job in a suitable "finished" state.
- jobrecord.running = false
- jobrecord.finished_at ||= Time.now
- if jobrecord.success.nil?
- jobrecord.success = false
- if exit_status.to_i != 75 and jobrecord.state == "Running"
++ if exit_status != 75 and jobrecord.state == "Running"
+ # crunch-job did not return exit code 75 (see below) and left the job in
+ # the "Running" state, which means there was an unhandled error. Fail
+ # the job.
+ jobrecord.state = "Failed"
- jobrecord.save!
++ if not jobrecord.save
++ $stderr.puts "dispatch: jobrecord.save failed"
+ end
- jobrecord.save!
else
# Don't fail the job if crunch-job didn't even get as far as
# starting it. If the job failed to run due to an infrastructure