mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:23:43 +08:00
Track error message in SchedulerStats
.
This commit is contained in:
parent
31a44a7c93
commit
1f6418f907
|
@ -17,4 +17,5 @@ end
|
||||||
# live_slots_finish :integer
|
# live_slots_finish :integer
|
||||||
# started_at :datetime not null
|
# started_at :datetime not null
|
||||||
# success :boolean
|
# success :boolean
|
||||||
|
# error :text
|
||||||
#
|
#
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddErrorToSchedulerStats < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :scheduler_stats, :error, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -78,6 +78,8 @@ module Scheduler
|
||||||
start = Time.now.to_f
|
start = Time.now.to_f
|
||||||
info = @mutex.synchronize { @manager.schedule_info(klass) }
|
info = @mutex.synchronize { @manager.schedule_info(klass) }
|
||||||
stat = nil
|
stat = nil
|
||||||
|
error = nil
|
||||||
|
|
||||||
begin
|
begin
|
||||||
info.prev_result = "RUNNING"
|
info.prev_result = "RUNNING"
|
||||||
@mutex.synchronize { info.write! }
|
@mutex.synchronize { info.write! }
|
||||||
|
@ -96,6 +98,7 @@ module Scheduler
|
||||||
failed = true
|
failed = true
|
||||||
rescue => e
|
rescue => e
|
||||||
Discourse.handle_job_exception(e, {message: "Running a scheduled job", job: klass})
|
Discourse.handle_job_exception(e, {message: "Running a scheduled job", job: klass})
|
||||||
|
error = "#{e.message}: #{e.backtrace.join("\n")}"
|
||||||
failed = true
|
failed = true
|
||||||
end
|
end
|
||||||
duration = ((Time.now.to_f - start) * 1000).to_i
|
duration = ((Time.now.to_f - start) * 1000).to_i
|
||||||
|
@ -103,10 +106,11 @@ module Scheduler
|
||||||
info.prev_result = failed ? "FAILED" : "OK"
|
info.prev_result = failed ? "FAILED" : "OK"
|
||||||
info.current_owner = nil
|
info.current_owner = nil
|
||||||
if stat
|
if stat
|
||||||
stat.update_columns(
|
stat.update!(
|
||||||
duration_ms: duration,
|
duration_ms: duration,
|
||||||
live_slots_finish: GC.stat[:heap_live_slots],
|
live_slots_finish: GC.stat[:heap_live_slots],
|
||||||
success: !failed
|
success: !failed,
|
||||||
|
error: error
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
attempts(3) do
|
attempts(3) do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user