mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 19:02:52 +02:00
More helpful error when renewing with standalone
This commit is contained in:
@@ -200,7 +200,8 @@ class Authenticator(common.Plugin):
|
|||||||
return self.supported_challenges
|
return self.supported_challenges
|
||||||
|
|
||||||
def perform(self, achalls): # pylint: disable=missing-docstring
|
def perform(self, achalls): # pylint: disable=missing-docstring
|
||||||
if any(util.already_listening(port) for port in self._necessary_ports):
|
renewer = self.config.verb == "renew"
|
||||||
|
if any(util.already_listening(port, renewer) for port in self._necessary_ports):
|
||||||
raise errors.MisconfigurationError(
|
raise errors.MisconfigurationError(
|
||||||
"At least one of the (possibly) required ports is "
|
"At least one of the (possibly) required ports is "
|
||||||
"already taken.")
|
"already taken.")
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
self.config.standalone_supported_challenges = chall
|
self.config.standalone_supported_challenges = chall
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
errors.MisconfigurationError, self.auth.perform, [])
|
errors.MisconfigurationError, self.auth.perform, [])
|
||||||
mock_util.already_listening.assert_called_once_with(port)
|
mock_util.already_listening.assert_called_once_with(port, False)
|
||||||
mock_util.already_listening.reset_mock()
|
mock_util.already_listening.reset_mock()
|
||||||
|
|
||||||
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from letsencrypt import interfaces
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def already_listening(port):
|
def already_listening(port, renewer=False):
|
||||||
"""Check if a process is already listening on the port.
|
"""Check if a process is already listening on the port.
|
||||||
|
|
||||||
If so, also tell the user via a display notification.
|
If so, also tell the user via a display notification.
|
||||||
@@ -49,11 +49,18 @@ def already_listening(port):
|
|||||||
pid = listeners[0]
|
pid = listeners[0]
|
||||||
name = psutil.Process(pid).name()
|
name = psutil.Process(pid).name()
|
||||||
display = zope.component.getUtility(interfaces.IDisplay)
|
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(
|
display.notification(
|
||||||
"The program {0} (process ID {1}) is already listening "
|
"The program {0} (process ID {1}) is already listening "
|
||||||
"on TCP port {2}. This will prevent us from binding to "
|
"on TCP port {2}. This will prevent us from binding to "
|
||||||
"that port. Please stop the {0} program temporarily "
|
"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
|
return True
|
||||||
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||||
# Perhaps the result of a race where the process could have
|
# Perhaps the result of a race where the process could have
|
||||||
|
|||||||
Reference in New Issue
Block a user