From 947dc02ce2a783be0d3121bbee48498639d3a758 Mon Sep 17 00:00:00 2001 From: Hendrik Jäger Date: Sat, 3 Feb 2024 20:48:43 +0100 Subject: change retry method to use recursion, raise exception if fails --- macir.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/macir.rb b/macir.rb index 8331da4..f923839 100644 --- a/macir.rb +++ b/macir.rb @@ -185,13 +185,14 @@ def wait_for_challenge_propagation(domain, challenge) threads.each(&:join) end -def acme_request_with_retries - retries ||= 0 - yield +def acme_request_with_retries(retries: 5, &block) + p "Retries: #{retries}" + block.call(self) rescue Acme::Client::Error::BadNonce - retries += 1 + raise unless retries.positive? + p 'Retrying because of invalid nonce.' - retry if retries <= 5 + acme_request_with_retries(retries: retries - 1, &block) end def wait_for_challenge_validation(challenge, cert_name) -- cgit v1.2.3