From 3c57f47856c85f762f3340b494167a7b5244f2ec Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Mon, 24 Sep 2018 16:56:30 -0700 Subject: [PATCH] WIP on adding a random sleep for noninteractive renewal --- certbot/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/certbot/main.py b/certbot/main.py index 214378da8..5afe06aa4 100644 --- a/certbot/main.py +++ b/certbot/main.py @@ -4,7 +4,9 @@ from __future__ import print_function import functools import logging.handlers import os +import random import sys +import time import configobj import josepy as jose @@ -1273,6 +1275,14 @@ def renew(config, unused_plugins): :rtype: None """ + if not sys.stdout.isatty(): + # Noninteractive renewals include a random delay in order to spread + # out the load on the certificate authority servers, even if many + # users all pick the same time for renewals. This delay precedes + # running any hooks, so that side effects of the hooks (such as + # shutting down a web service) aren't prolonged unnecessarily. + time.sleep(random.randint(1, 60*8)) + try: renewal.handle_renewal_request(config) finally: