From e5c4cb0344374d2af1a56e4b982b746a635108b5 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 19 Feb 2023 15:34:36 +0100 Subject: [PATCH] Retry healthcheck for up to 10 seconds (in case container wasnt ready) --- lib/mrsk/commands/healthcheck.rb | 2 +- test/commands/healthcheck_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mrsk/commands/healthcheck.rb b/lib/mrsk/commands/healthcheck.rb index 34ff3a46..12d89b45 100644 --- a/lib/mrsk/commands/healthcheck.rb +++ b/lib/mrsk/commands/healthcheck.rb @@ -16,7 +16,7 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base end def curl - [ :curl, "--silent", "--output", "/dev/null", "--write-out", "'%{http_code}'", health_url ] + [ :curl, "--silent", "--output", "/dev/null", "--write-out", "'%{http_code}'", "--retry-max-time", 10, "--retry", 5, health_url ] end def logs diff --git a/test/commands/healthcheck_test.rb b/test/commands/healthcheck_test.rb index 0216fa1f..2ef7df81 100644 --- a/test/commands/healthcheck_test.rb +++ b/test/commands/healthcheck_test.rb @@ -24,7 +24,7 @@ class CommandsHealthcheckTest < ActiveSupport::TestCase test "curl" do assert_equal \ - "curl --silent --output /dev/null --write-out '%{http_code}' http://localhost:3999/up", + "curl --silent --output /dev/null --write-out '%{http_code}' --retry-max-time 10 --retry 5 http://localhost:3999/up", new_command.curl.join(" ") end @@ -32,7 +32,7 @@ class CommandsHealthcheckTest < ActiveSupport::TestCase @config[:healthcheck] = { "path" => "/healthz" } assert_equal \ - "curl --silent --output /dev/null --write-out '%{http_code}' http://localhost:3999/healthz", + "curl --silent --output /dev/null --write-out '%{http_code}' --retry-max-time 10 --retry 5 http://localhost:3999/healthz", new_command.curl.join(" ") end