|
|
@ -19,6 +19,53 @@ class DelayedJobNeverRanCheck < OkComputer::Check |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PumaCheck < OkComputer::Check |
|
|
|
|
|
|
|
attr_reader :threshold |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(backlog_threshold) |
|
|
|
|
|
|
|
@threshold = backlog_threshold.to_i |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check |
|
|
|
|
|
|
|
stats = self.stats |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mark_message "N/A as Puma is not used." if stats.nil? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if stats[:running] > 0 |
|
|
|
|
|
|
|
mark_message "Puma is running" |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
mark_failure |
|
|
|
|
|
|
|
mark_message "Puma is not running" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if stats[:backlog] < threshold |
|
|
|
|
|
|
|
mark_message "Backlog ok" |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
mark_failure |
|
|
|
|
|
|
|
mark_message "Backlog congested" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stats |
|
|
|
|
|
|
|
return nil unless applicable? |
|
|
|
|
|
|
|
server = Puma::Server.current |
|
|
|
|
|
|
|
return nil if server.nil? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
backlog: server.backlog || 0, |
|
|
|
|
|
|
|
running: server.running || 0, |
|
|
|
|
|
|
|
pool_capacity: server.pool_capacity || 0, |
|
|
|
|
|
|
|
max_threads: server.max_threads || 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def applicable? |
|
|
|
|
|
|
|
return @applicable unless @applicable.nil? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@applicable = Object.const_defined?("Puma::Server") && !Puma::Server.current.nil? |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Register delayed_job backed up test |
|
|
|
# Register delayed_job backed up test |
|
|
|
dj_max = OpenProject::Configuration.health_checks_jobs_queue_count_threshold |
|
|
|
dj_max = OpenProject::Configuration.health_checks_jobs_queue_count_threshold |
|
|
|
OkComputer::Registry.register "delayed_jobs_backed_up", |
|
|
|
OkComputer::Registry.register "delayed_jobs_backed_up", |
|
|
@ -28,8 +75,11 @@ dj_never_ran_max = OpenProject::Configuration.health_checks_jobs_never_ran_minut |
|
|
|
OkComputer::Registry.register "delayed_jobs_never_ran", |
|
|
|
OkComputer::Registry.register "delayed_jobs_never_ran", |
|
|
|
DelayedJobNeverRanCheck.new(dj_never_ran_max) |
|
|
|
DelayedJobNeverRanCheck.new(dj_never_ran_max) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backlog_threshold = OpenProject::Configuration.health_checks_backlog_threshold |
|
|
|
|
|
|
|
OkComputer::Registry.register "puma", PumaCheck.new(backlog_threshold) |
|
|
|
|
|
|
|
|
|
|
|
# Make dj backed up optional due to bursts |
|
|
|
# Make dj backed up optional due to bursts |
|
|
|
OkComputer.make_optional %w(delayed_jobs_backed_up) |
|
|
|
OkComputer.make_optional %w(delayed_jobs_backed_up puma) |
|
|
|
|
|
|
|
|
|
|
|
# Register web worker check for web + database |
|
|
|
# Register web worker check for web + database |
|
|
|
OkComputer::CheckCollection.new('web').tap do |collection| |
|
|
|
OkComputer::CheckCollection.new('web').tap do |collection| |
|
|
@ -45,6 +95,7 @@ OkComputer::CheckCollection.new('full').tap do |collection| |
|
|
|
collection.register :mail, OkComputer::ActionMailerCheck.new |
|
|
|
collection.register :mail, OkComputer::ActionMailerCheck.new |
|
|
|
collection.register :delayed_jobs_backed_up, OkComputer::Registry.fetch('delayed_jobs_backed_up') |
|
|
|
collection.register :delayed_jobs_backed_up, OkComputer::Registry.fetch('delayed_jobs_backed_up') |
|
|
|
collection.register :delayed_jobs_never_ran, OkComputer::Registry.fetch('delayed_jobs_never_ran') |
|
|
|
collection.register :delayed_jobs_never_ran, OkComputer::Registry.fetch('delayed_jobs_never_ran') |
|
|
|
|
|
|
|
collection.register :puma, OkComputer::Registry.fetch('puma') |
|
|
|
OkComputer::Registry.default_collection.register 'full', collection |
|
|
|
OkComputer::Registry.default_collection.register 'full', collection |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|