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 --- tests/__init__.py | 5 ----- tests/robot/__main__.py | 9 --------- 2 files changed, 14 deletions(-) (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py index e68d72feb..55a002196 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,13 +5,8 @@ import pathlib import os import aiounittest -# Before import from the searx package, we need to set up the (debug) -# environment. The import of the searx package initialize the searx.settings -# and this in turn takes the defaults from the environment! os.environ.pop('SEARXNG_SETTINGS_PATH', None) -os.environ['SEARXNG_DEBUG'] = '1' -os.environ['SEARXNG_DEBUG_LOG_LEVEL'] = 'WARNING' os.environ['SEARXNG_DISABLE_ETC_SETTINGS'] = '1' diff --git a/tests/robot/__main__.py b/tests/robot/__main__.py index 0b438745e..a18dd9e26 100644 --- a/tests/robot/__main__.py +++ b/tests/robot/__main__.py @@ -27,15 +27,6 @@ class SearxRobotLayer: webapp = str(tests_path.parent / 'searx' / 'webapp.py') exe = 'python' - # The Flask app is started by Flask.run(...), don't enable Flask's debug - # mode, the debugger from Flask will cause wired process model, where - # the server never dies. Further read: - # - # - debug mode: https://flask.palletsprojects.com/quickstart/#debug-mode - # - Flask.run(..): https://flask.palletsprojects.com/api/#flask.Flask.run - - os.environ['SEARXNG_DEBUG'] = '0' - # set robot settings path os.environ['SEARXNG_SETTINGS_PATH'] = str(tests_path / 'robot' / 'settings_robot.yml') -- cgit v1.2.3