mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +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
Gemfile
1
Gemfile
|
@ -47,6 +47,7 @@ gem 'acme-client', {
|
|||
git: 'https://github.com/jhass/acme-client.git',
|
||||
branch: 'no_activesupport'
|
||||
}
|
||||
gem 'http'
|
||||
|
||||
platform :mri, :rbx do
|
||||
gem 'magic' # sudo apt-get install file, For OSX: brew install libmagic
|
||||
|
|
|
@ -97,8 +97,15 @@ GEM
|
|||
hiredis (0.6.1)
|
||||
hoe (3.14.2)
|
||||
rake (>= 0.8, < 11.0)
|
||||
http (2.0.1)
|
||||
addressable (~> 2.3)
|
||||
http-cookie (~> 1.0)
|
||||
http-form_data (~> 1.0.1)
|
||||
http_parser.rb (~> 0.6.0)
|
||||
http-cookie (1.0.2)
|
||||
domain_name (~> 0.5)
|
||||
http-form_data (1.0.1)
|
||||
http_parser.rb (0.6.0)
|
||||
i18n (0.7.0)
|
||||
io-extra (1.2.8)
|
||||
jimson-temp (0.9.5)
|
||||
|
@ -280,6 +287,7 @@ DEPENDENCIES
|
|||
geoip
|
||||
hiredis
|
||||
hoe (= 3.14.2)
|
||||
http
|
||||
io-extra
|
||||
jdbc-postgres
|
||||
jruby-openssl
|
||||
|
|
|
@ -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
Reference in a new issue