discourse/app/services/problem_check/sidekiq_check.rb
Ted Johansson 3137e60653
DEV: Database backed admin notices (#26192)
This PR introduces a basic AdminNotice model to store these notices. Admin notices are categorized by their source/type (currently only notices from problem check.) They also have a priority.
2024-05-23 09:29:08 +08:00

39 lines
715 B
Ruby

# frozen_string_literal: true
class ProblemCheck::SidekiqCheck < ProblemCheck
self.priority = "low"
def call
if jobs_in_queue? && !jobs_performed_recently?
return problem(override_key: "dashboard.problem.sidekiq")
end
if massive_queue?
return(
problem(
override_key: "dashboard.problem.queue_size",
override_data: {
queue_size: Jobs.queued,
},
)
)
end
no_problem
end
private
def massive_queue?
Jobs.queued >= 100_000
end
def jobs_in_queue?
Jobs.queued > 0
end
def jobs_performed_recently?
Jobs.last_job_performed_at.present? && Jobs.last_job_performed_at > 2.minutes.ago
end
end