From ed44cc5a172dec95a4d0d34082898aeb3c6a1223 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Tue, 28 Jun 2016 03:50:03 +0000 Subject: [PATCH] Script to periodically renew certs (run with cronjob) --- Rakefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index fd2c0254..db3c10ef 100644 --- a/Rakefile +++ b/Rakefile @@ -383,7 +383,7 @@ end desc 'regenerate_ssl_certs' task :regenerate_ssl_certs => [:environment] do - sites = DB[%{select id from sites where ((domain is not null or domain != '') and is_banned != 't' and is_deleted != 't' and plan_type is not null and plan_type != 'free') or parent_site_id is not null}].all + sites = DB[%{select id from sites where (domain is not null or domain != '') and is_banned != 't' and is_deleted != 't'}].all seconds = 2 @@ -394,3 +394,12 @@ task :regenerate_ssl_certs => [:environment] do puts "#{sites.length.to_s} records are primed" end + +desc 'renew_ssl_certs' +task :renew_ssl_certs => [:environment] do + delay = 0 + DB[%{select id from sites where (domain is not null or domain != '') and is_banned != 't' and is_deleted != 't' and (cert_updated_at is null or cert_updated_at < ?)}, 60.days.ago].all.each do |site| + LetsEncryptWorker.perform_in delay.seconds, site[:id] + delay += 10 + end +end