mirror of
https://github.com/neocities/neocities.git
synced 2025-05-28 16:30:06 +02:00
try to deal with rate limiting
This commit is contained in:
parent
3d73172246
commit
8a109f7b4b
3 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue