Track error message in SchedulerStats.

This commit is contained in:
Guo Xiang Tan
2017-04-26 01:33:38 +08:00
parent 31a44a7c93
commit 1f6418f907
3 changed files with 12 additions and 2 deletions

View File

@ -78,6 +78,8 @@ module Scheduler
start = Time.now.to_f
info = @mutex.synchronize { @manager.schedule_info(klass) }
stat = nil
error = nil
begin
info.prev_result = "RUNNING"
@mutex.synchronize { info.write! }
@ -96,6 +98,7 @@ module Scheduler
failed = true
rescue => e
Discourse.handle_job_exception(e, {message: "Running a scheduled job", job: klass})
error = "#{e.message}: #{e.backtrace.join("\n")}"
failed = true
end
duration = ((Time.now.to_f - start) * 1000).to_i
@ -103,10 +106,11 @@ module Scheduler
info.prev_result = failed ? "FAILED" : "OK"
info.current_owner = nil
if stat
stat.update_columns(
stat.update!(
duration_ms: duration,
live_slots_finish: GC.stat[:heap_live_slots],
success: !failed
success: !failed,
error: error
)
end
attempts(3) do