try to deal with rate limiting

This commit is contained in:
Kyle Drake 2016-06-23 16:05:26 -07:00
parent 3d73172246
commit 8a109f7b4b
3 changed files with 20 additions and 1 deletions

View file

@ -1,6 +1,7 @@
class LetsEncryptWorker
class NotAuthorizedYetError < StandardError; end
class VerificationTimeoutError < StandardError; end
class VerifyNotFoundWithDomain < StandardError; end
include Sidekiq::Worker
sidekiq_options queue: :lets_encrypt_worker, retry: 100, backtrace: true
@ -36,9 +37,18 @@ class LetsEncryptWorker
FileUtils.mkdir_p File.join(site.base_files_path, File.dirname(challenge.filename)) if index == 0
File.write File.join(site.base_files_path, challenge.filename), challenge.file_content
# Ensure that both domains work before sending request. Let's Encrypt has a low
# pending request limit, and it takes one week (!) to flush out.
sleep 2
challenge_url = "#{domain}/#{challenge.filename}"
["http://#{challenge_url}", "http://www.#{challenge_url}"].each do |url|
res = HTTP.follow.get(url)
raise VerifyNotFoundWithDomain unless res.status == 200
end
challenge.request_verification
sleep 1
sleep 60
attempts = 0
begin