From e9157b3c1a502a5898d370c0e98cc3e5ef8ef3f0 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 9 Apr 2025 14:01:01 +0200 Subject: [fix] issues when launching a local development server A local development server can be launched by one of these command lines:: $ flask --app searx.webapp run $ python -m searx.webapp The different ways of starting the server should lead to the same result, which is generally the case. However, if the modules are reloaded after code changes (reload option), it must be avoided that the application is initialized twice at startup. We have already discussed this in 2022 [1][2]. Further information on this topic can be found in [3][4][5]. To test a bash in the ./local environment was started and the follwing commands had been executed:: $ ./manage pyenv.cmd bash --norc --noprofile (py3) SEARXNG_DEBUG=1 flask --app searx.webapp run --reload (py3) SEARXNG_DEBUG=1 python -m searx.webapp Since the generic parts of the docs also initialize the app to generate doc from it, the build of the docs was also tested:: $ make docs.clean docs.live [1] https://github.com/searxng/searxng/pull/1656#issuecomment-1214198941 [2] https://github.com/searxng/searxng/pull/1616#issuecomment-1206137468 [3] https://flask.palletsprojects.com/en/stable/api/#flask.Flask.run [4] https://github.com/pallets/flask/issues/5307#issuecomment-1774646119 [5] https://stackoverflow.com/a/25504196 Signed-off-by: Markus Heiser --- searx/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'searx/__init__.py') diff --git a/searx/__init__.py b/searx/__init__.py index 933c49c20..ee77a523e 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -22,18 +22,18 @@ searx_dir = abspath(dirname(__file__)) searx_parent_dir = abspath(dirname(dirname(__file__))) settings = {} -searx_debug = False +sxng_debug = False logger = logging.getLogger('searx') _unset = object() def init_settings(): - """Initialize global ``settings`` and ``searx_debug`` variables and + """Initialize global ``settings`` and ``sxng_debug`` variables and ``logger`` from ``SEARXNG_SETTINGS_PATH``. """ - global settings, searx_debug # pylint: disable=global-variable-not-assigned + global settings, sxng_debug # pylint: disable=global-variable-not-assigned cfg, msg = searx.settings_loader.load_settings(load_user_settings=True) cfg = cfg or {} @@ -42,8 +42,8 @@ def init_settings(): settings.clear() settings.update(cfg) - searx_debug = settings['general']['debug'] - if searx_debug: + sxng_debug = get_setting("general.debug") + if sxng_debug: _logging_config_debug() else: logging.basicConfig(level=LOG_LEVEL_PROD, format=LOG_FORMAT_PROD) -- cgit v1.2.3