From 2039060b640189e250020e6e17db10b0a0730e7e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 12 Jun 2024 18:01:18 +0200 Subject: [mod] revision of the settings_loader The intention of this PR is to modernize the settings_loader implementations. The concept is old (remember, this is partly from 2014), back then we only had one config file, meanwhile we have had a folder with config files for a very long time. Callers can now load a YAML configuration from this folder as follows :: settings_loader.get_yaml_cfg('my-config.yml') - BTW this is a fix of #3557. - Further the `existing_filename_or_none` construct dates back to times when there was not yet a `pathlib.Path` in all Python versions we supported in the past. - Typehints have been added wherever appropriate At the same time, this patch should also be downward compatible and not introduce a new environment variable. The localization of the folder with the configurations is further based on: SEARXNG_SETTINGS_PATH (wich defaults to /etc/searxng/settings.yml) Which means, the default config folder is `/etc/searxng/`. ATTENTION: intended functional changes! If SEARXNG_SETTINGS_PATH was set and pointed to a not existing file, the previous implementation silently loaded the default configuration. This behavior has been changed: if the file or folder does not exist, an EnvironmentError exception will be thrown in future. Closes: https://github.com/searxng/searxng/issues/3557 Signed-off-by: Markus Heiser --- searx/webapp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'searx/webapp.py') diff --git a/searx/webapp.py b/searx/webapp.py index b2b6a0bb5..4ecc9559e 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -61,7 +61,7 @@ from searx.botdetection import link_token from searx.data import ENGINE_DESCRIPTIONS from searx.results import Timing from searx.settings_defaults import OUTPUT_FORMATS -from searx.settings_loader import get_default_settings_path +from searx.settings_loader import DEFAULT_SETTINGS_FILE from searx.exceptions import SearxParameterException from searx.engines import ( DEFAULT_CATEGORY, @@ -1347,7 +1347,7 @@ def run(): port=settings['server']['port'], host=settings['server']['bind_address'], threaded=True, - extra_files=[get_default_settings_path()], + extra_files=[DEFAULT_SETTINGS_FILE], ) -- cgit v1.2.3