mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
Letsencrypt gets very mad at too many pending auths, adjust times
This commit is contained in:
parent
aa6cd46eeb
commit
568a7e9900
1 changed files with 16 additions and 6 deletions
|
@ -2,10 +2,10 @@ class LetsEncryptWorker
|
||||||
class NotAuthorizedYetError < StandardError; end
|
class NotAuthorizedYetError < StandardError; end
|
||||||
class VerificationTimeoutError < StandardError; end
|
class VerificationTimeoutError < StandardError; end
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
sidekiq_options queue: :lets_encrypt_worker, retry: 100, backtrace: true
|
sidekiq_options queue: :lets_encrypt_worker, retry: 5, backtrace: true
|
||||||
|
|
||||||
sidekiq_retry_in do |count|
|
sidekiq_retry_in do |count|
|
||||||
180
|
1.hour.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def letsencrypt
|
def letsencrypt
|
||||||
|
@ -43,14 +43,16 @@ class LetsEncryptWorker
|
||||||
|
|
||||||
begin
|
begin
|
||||||
puts "WAITING FOR #{domain} VALIDATION"
|
puts "WAITING FOR #{domain} VALIDATION"
|
||||||
raise VerificationTimeoutError if attempts == 5
|
|
||||||
|
raise VerificationTimeoutError if attempts == 60
|
||||||
raise NotAuthorizedYetError if challenge.verify_status != 'valid'
|
raise NotAuthorizedYetError if challenge.verify_status != 'valid'
|
||||||
rescue NotAuthorizedYetError
|
rescue NotAuthorizedYetError
|
||||||
sleep 5
|
sleep 20
|
||||||
attempts += 1
|
attempts += 1
|
||||||
retry
|
retry
|
||||||
|
ensure
|
||||||
|
clean_wellknown_turds site
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "DONE!"
|
puts "DONE!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,9 +61,17 @@ class LetsEncryptWorker
|
||||||
site.ssl_key = certificate.request.private_key.to_pem
|
site.ssl_key = certificate.request.private_key.to_pem
|
||||||
site.ssl_cert = certificate.fullchain_to_pem
|
site.ssl_cert = certificate.fullchain_to_pem
|
||||||
site.save_changes validate: false
|
site.save_changes validate: false
|
||||||
FileUtils.rm_rf File.join(site.base_files_path, '.well-known')
|
clean_wellknown_turds site
|
||||||
|
|
||||||
# Refresh the cert periodically, current expire time is 90 days
|
# Refresh the cert periodically, current expire time is 90 days
|
||||||
LetsEncryptWorker.perform_in 60.days, site.id
|
LetsEncryptWorker.perform_in 60.days, site.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clean_wellknown_turds(site)
|
||||||
|
wellknown_path = File.join(site.base_files_path, '.well-known')
|
||||||
|
|
||||||
|
if File.exist?(wellknown_path)
|
||||||
|
FileUtils.rm_rf wellknown_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue