More helpful error when renewing with standalone

This commit is contained in:
Peter Eckersley
2016-02-02 16:47:42 -08:00
parent 2c200b1e43
commit ccd58dea5b
3 changed files with 12 additions and 4 deletions
+9 -2
View File
@@ -11,7 +11,7 @@ from letsencrypt import interfaces
logger = logging.getLogger(__name__)
def already_listening(port):
def already_listening(port, renewer=False):
"""Check if a process is already listening on the port.
If so, also tell the user via a display notification.
@@ -49,11 +49,18 @@ def already_listening(port):
pid = listeners[0]
name = psutil.Process(pid).name()
display = zope.component.getUtility(interfaces.IDisplay)
extra = ""
if renewer:
extra = (" For automated renewal, you may want to use a script that stops"
" and starts your webserver. You can find an example at"
" https://letsencrypt.org/howitworks/#writing-your-own-renewal-script"
". Alternatively you can use the webroot plugin to renew without"
" needing to stop and start your webserver.")
display.notification(
"The program {0} (process ID {1}) is already listening "
"on TCP port {2}. This will prevent us from binding to "
"that port. Please stop the {0} program temporarily "
"and then try again.".format(name, pid, port))
"and then try again.{3}".format(name, pid, port, extra))
return True
except (psutil.NoSuchProcess, psutil.AccessDenied):
# Perhaps the result of a race where the process could have