Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

54 Zeilen
1.8 KiB

  1. # Copyright 2014-2016 OpenMarket Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import logging
  15. import sys
  16. from typing import Container
  17. from synapse.util import check_dependencies
  18. logger = logging.getLogger(__name__)
  19. try:
  20. check_dependencies.check_requirements()
  21. except check_dependencies.DependencyException as e:
  22. sys.stderr.writelines(
  23. e.message # noqa: B306, DependencyException.message is a property
  24. )
  25. sys.exit(1)
  26. def check_bind_error(
  27. e: Exception, address: str, bind_addresses: Container[str]
  28. ) -> None:
  29. """
  30. This method checks an exception occurred while binding on 0.0.0.0.
  31. If :: is specified in the bind addresses a warning is shown.
  32. The exception is still raised otherwise.
  33. Binding on both 0.0.0.0 and :: causes an exception on Linux and macOS
  34. because :: binds on both IPv4 and IPv6 (as per RFC 3493).
  35. When binding on 0.0.0.0 after :: this can safely be ignored.
  36. Args:
  37. e: Exception that was caught.
  38. address: Address on which binding was attempted.
  39. bind_addresses: Addresses on which the service listens.
  40. """
  41. if address == "0.0.0.0" and "::" in bind_addresses:
  42. logger.warning(
  43. "Failed to listen on 0.0.0.0, continuing because listening on [::]"
  44. )
  45. else:
  46. raise e