示例#1
0
def late_init() -> None:
    """Initialization that needs to be called after QLDS has finished
    its own initialization.

    """
    minqlx.initialize_cvars()

    # Set the default database plugins should use.
    # TODO: Make Plugin.database setting generic.
    database_cvar = minqlx.get_cvar("qlx_database")
    if database_cvar is not None and database_cvar.lower() == "redis":
        minqlx.Plugin.database = minqlx.database.Redis

    # Get the plugins path and set minqlx.__plugins_version__.
    plugins_path_cvar = minqlx.get_cvar("qlx_pluginsPath")
    if plugins_path_cvar is not None:
        plugins_path = os.path.abspath(plugins_path_cvar)
        set_plugins_version(plugins_path)

        # Add the plugins path to PATH so that we can load plugins later.
        sys.path.append(os.path.dirname(plugins_path))

    # Initialize the logger now that we have fs_basepath.
    _configure_logger()
    logger = get_logger()
    # Set our own exception handler so that we can log them if unhandled.
    sys.excepthook = handle_exception

    if sys.version_info >= (3, 8):
        threading.excepthook = threading_excepthook

    logger.info("Loading preset plugins...")
    load_preset_plugins()

    stats_enable_cvar = minqlx.get_cvar("zmq_stats_enable")
    if stats_enable_cvar is not None and bool(int(stats_enable_cvar)):
        global _stats  # pylint: disable=global-statement
        _stats = minqlx.StatsListener()
        logger.info("Stats listener started on %s.", _stats.address)
        # Start polling. Not blocking due to decorator magic. Aw yeah.
        _stats.keep_receiving()

    logger.info("We're good to go!")
示例#2
0
文件: _core.py 项目: MinoMino/minqlx
def late_init():
    """Initialization that needs to be called after QLDS has finished
    its own initialization.

    """
    minqlx.initialize_cvars()

    # Set the default database plugins should use.
    # TODO: Make Plugin.database setting generic.
    if minqlx.get_cvar("qlx_database").lower() == "redis":
        minqlx.Plugin.database = minqlx.database.Redis

    # Get the plugins path and set minqlx.__plugins_version__.
    plugins_path = os.path.abspath(minqlx.get_cvar("qlx_pluginsPath"))
    set_plugins_version(plugins_path)

    # Initialize the logger now that we have fs_basepath.
    _configure_logger()
    logger = get_logger()
    # Set our own exception handler so that we can log them if unhandled.
    sys.excepthook = handle_exception

    # Add the plugins path to PATH so that we can load plugins later.
    sys.path.append(os.path.dirname(plugins_path))

    logger.info("Loading preset plugins...")
    load_preset_plugins()

    if bool(int(minqlx.get_cvar("zmq_stats_enable"))):
        global _stats
        _stats = minqlx.StatsListener()
        logger.info("Stats listener started on {}.".format(_stats.address))
        # Start polling. Not blocking due to decorator magic. Aw yeah.
        _stats.keep_receiving()

    logger.info("We're good to go!")