Refactoring: Make Scheduler more robust against job deletion while processing.

This commit is contained in:
Thorsten Eckel 2018-12-03 12:27:51 +01:00
parent 1be60c91db
commit b5a44ee0d0

View file

@ -257,13 +257,20 @@ class Scheduler < ApplicationModel
else
_start_job(job)
end
if job.present?
job.pid = ''
job.save
logger.info " ...stopped thread for '#{job.method}'"
ActiveRecord::Base.connection.close
# release thread lock and remove thread handle
@@jobs_started.delete(job.id)
else
logger.warn ' ...Job got deleted while running'
end
ActiveRecord::Base.connection.close
end
end