logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 3e7554422b7d177e12838882ed0b84878278825e
parent: e249698b26fcf40ea8fc36897297cc1879fe8ce2
Author: dalf <alex@al-f.net>
Date:   Sat, 22 Oct 2016 19:07:37 +0200

[mod] the environment variable SEARX_DEBUG can override the general.debug value in settings.yml

Diffstat:

searx/__init__.py | 21++++++++++++++++++++-
searx/webapp.py | 6+++---
2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/searx/__init__.py b/searx/__init__.py @@ -42,7 +42,26 @@ else: with open(settings_path) as settings_yaml: settings = load(settings_yaml) -if settings.get('general', {}).get('debug'): +''' +enable debug if +the environnement variable SEARX_DEBUG is 1 or true +(whatever the value in settings.yml) +or general.debug=True in settings.yml + +disable debug if +the environnement variable SEARX_DEBUG is 0 or false +(whatever the value in settings.yml) +or general.debug=False in settings.yml +''' +searx_debug_env = environ.get('SEARX_DEBUG', '').lower() +if searx_debug_env == 'true' or searx_debug_env == '1': + searx_debug = True +elif searx_debug_env == 'false' or searx_debug_env == '0': + searx_debug = False +else: + searx_debug = settings.get('general', {}).get('debug') + +if searx_debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.WARNING) diff --git a/searx/webapp.py b/searx/webapp.py @@ -51,7 +51,7 @@ from flask import ( ) from flask_babel import Babel, gettext, format_date, format_decimal from flask.json import jsonify -from searx import settings, searx_dir +from searx import settings, searx_dir, searx_debug from searx.engines import ( categories, engines, get_engines_stats, engine_shortcuts ) @@ -743,8 +743,8 @@ def page_not_found(e): def run(): app.run( - debug=settings['general']['debug'], - use_debugger=settings['general']['debug'], + debug=searx_debug, + use_debugger=searx_debug, port=settings['server']['port'], host=settings['server']['bind_address'], threaded=True