authentik.lib.debug

 1from structlog.stdlib import get_logger
 2
 3from authentik.lib.config import CONFIG
 4
 5LOGGER = get_logger()
 6
 7
 8def start_debug_server(**kwargs) -> bool:
 9    """Attempt to start a debugpy server in the current process.
10    Returns true if the server was started successfully, otherwise false"""
11    if not CONFIG.get_bool("debug") and not CONFIG.get_bool("debugger"):
12        return
13    try:
14        import debugpy
15    except ImportError:
16        LOGGER.warning(
17            "Failed to import debugpy. debugpy is not included "
18            "in the default release dependencies and must be installed manually"
19        )
20        return False
21
22    listen: str = CONFIG.get("listen.debug_py", "127.0.0.1:9901")
23    host, _, port = listen.rpartition(":")
24    try:
25        debugpy.listen((host, int(port)), **kwargs)  # nosec
26    except RuntimeError:
27        LOGGER.warning("Could not start debug server. Continuing without")
28        return False
29    LOGGER.debug("Starting debug server", host=host, port=port)
30    return True
LOGGER = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>
def start_debug_server(**kwargs) -> bool:
 9def start_debug_server(**kwargs) -> bool:
10    """Attempt to start a debugpy server in the current process.
11    Returns true if the server was started successfully, otherwise false"""
12    if not CONFIG.get_bool("debug") and not CONFIG.get_bool("debugger"):
13        return
14    try:
15        import debugpy
16    except ImportError:
17        LOGGER.warning(
18            "Failed to import debugpy. debugpy is not included "
19            "in the default release dependencies and must be installed manually"
20        )
21        return False
22
23    listen: str = CONFIG.get("listen.debug_py", "127.0.0.1:9901")
24    host, _, port = listen.rpartition(":")
25    try:
26        debugpy.listen((host, int(port)), **kwargs)  # nosec
27    except RuntimeError:
28        LOGGER.warning("Could not start debug server. Continuing without")
29        return False
30    LOGGER.debug("Starting debug server", host=host, port=port)
31    return True

Attempt to start a debugpy server in the current process. Returns true if the server was started successfully, otherwise false