Przeglądaj źródła

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

dalf 8 lat temu
rodzic
commit
3e7554422b
2 zmienionych plików z 23 dodań i 4 usunięć
  1. 20
    1
      searx/__init__.py
  2. 3
    3
      searx/webapp.py

+ 20
- 1
searx/__init__.py Wyświetl plik

@@ -42,7 +42,26 @@ else:
42 42
 with open(settings_path) as settings_yaml:
43 43
     settings = load(settings_yaml)
44 44
 
45
-if settings.get('general', {}).get('debug'):
45
+'''
46
+enable debug if
47
+the environnement variable SEARX_DEBUG is 1 or true
48
+(whatever the value in settings.yml)
49
+or general.debug=True in settings.yml
50
+
51
+disable debug if
52
+the environnement variable SEARX_DEBUG is 0 or false
53
+(whatever the value in settings.yml)
54
+or general.debug=False in settings.yml
55
+'''
56
+searx_debug_env = environ.get('SEARX_DEBUG', '').lower()
57
+if searx_debug_env == 'true' or searx_debug_env == '1':
58
+    searx_debug = True
59
+elif searx_debug_env == 'false' or searx_debug_env == '0':
60
+    searx_debug = False
61
+else:
62
+    searx_debug = settings.get('general', {}).get('debug')
63
+
64
+if searx_debug:
46 65
     logging.basicConfig(level=logging.DEBUG)
47 66
 else:
48 67
     logging.basicConfig(level=logging.WARNING)

+ 3
- 3
searx/webapp.py Wyświetl plik

@@ -51,7 +51,7 @@ from flask import (
51 51
 )
52 52
 from flask_babel import Babel, gettext, format_date, format_decimal
53 53
 from flask.json import jsonify
54
-from searx import settings, searx_dir
54
+from searx import settings, searx_dir, searx_debug
55 55
 from searx.engines import (
56 56
     categories, engines, get_engines_stats, engine_shortcuts
57 57
 )
@@ -743,8 +743,8 @@ def page_not_found(e):
743 743
 
744 744
 def run():
745 745
     app.run(
746
-        debug=settings['general']['debug'],
747
-        use_debugger=settings['general']['debug'],
746
+        debug=searx_debug,
747
+        use_debugger=searx_debug,
748 748
         port=settings['server']['port'],
749 749
         host=settings['server']['bind_address'],
750 750
         threaded=True