13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/docktor_rails/checks/compose_healthchecks.rb', line 13
def run(ctx)
root = ctx.fetch(:root)
compose_path = Compose.find_file(root)
return pass("No compose file found (skipping healthcheck check)") unless compose_path
doc = Compose.load_file(compose_path)
services = Compose.services(doc)
targets = %w[db redis].select { |name| services.key?(name) }
return pass("No db/redis services detected") if targets.empty?
missing = targets.reject do |name|
svc = services[name]
svc.is_a?(Hash) && svc.key?("healthcheck") && !svc["healthcheck"].nil?
end
if missing.empty?
pass("Healthchecks present for db/redis")
else
warn("Missing healthchecks for: #{missing.join(", ")}", hint: "Add compose healthchecks so readiness is deterministic across machines.")
end
end
|