Browse Source

[fix] follow up of PR-1856

- the environment variable SEARXNG_REDIS_URL overrides the setting value redis.url
- ./manage sets SEARXNG_REDIS_URL to unix:///usr/local/searxng-redis/run/redis.sock if:
   - the socket exists
   - SEARXNG_REDIS_URL is not already defined

Update of PR #1856

Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
Alexandre Flament 2 years ago
parent
commit
34e260f88f
2 changed files with 13 additions and 1 deletions
  1. 12 0
      manage
  2. 1 1
      searx/settings_defaults.py

+ 12 - 0
manage

@@ -32,6 +32,12 @@ export NODE_MINIMUM_VERSION="16.13.0"
 BLACK_OPTIONS=("--target-version" "py37" "--line-length" "120" "--skip-string-normalization")
 BLACK_OPTIONS=("--target-version" "py37" "--line-length" "120" "--skip-string-normalization")
 BLACK_TARGETS=("--exclude" "searx/static,searx/languages.py" "--include" 'searxng.msg|\.pyi?$' "searx" "searxng_extra" "tests")
 BLACK_TARGETS=("--exclude" "searx/static,searx/languages.py" "--include" 'searxng.msg|\.pyi?$' "searx" "searxng_extra" "tests")
 
 
+_dev_redis_sock="/usr/local/searxng-redis/run/redis.sock"
+# set SEARXNG_REDIS_URL if it is not defined and "{_dev_redis_sock}" exists.
+if [ -S "${_dev_redis_sock}" ] && [ -z "${SEARXNG_REDIS_URL}" ]; then
+    export SEARXNG_REDIS_URL="unix://${_dev_redis_sock}?db=0"
+fi
+
 pylint.FILES() {
 pylint.FILES() {
 
 
     # List files tagged by comment:
     # List files tagged by comment:
@@ -65,6 +71,8 @@ help() {
     cat <<EOF
     cat <<EOF
 buildenv:
 buildenv:
   rebuild ./utils/brand.env
   rebuild ./utils/brand.env
+webapp.:
+  run       : run developer instance
 weblate.:
 weblate.:
   push.translations: push translation changes from SearXNG to Weblate's counterpart
   push.translations: push translation changes from SearXNG to Weblate's counterpart
   to.translations: Update 'translations' branch with last additions from Weblate.
   to.translations: Update 'translations' branch with last additions from Weblate.
@@ -121,6 +129,10 @@ pygments.:
 EOF
 EOF
     go.help
     go.help
     static_help
     static_help
+    cat <<EOF
+environment ...
+  SEARXNG_REDIS_URL : ${SEARXNG_REDIS_URL}
+EOF
 }
 }
 
 
 
 

+ 1 - 1
searx/settings_defaults.py

@@ -174,7 +174,7 @@ SCHEMA = {
         'default_http_headers': SettingsValue(dict, {}),
         'default_http_headers': SettingsValue(dict, {}),
     },
     },
     'redis': {
     'redis': {
-        'url': SettingsValue((None, False, str), False),
+        'url': SettingsValue((None, False, str), False, 'SEARXNG_REDIS_URL'),
     },
     },
     'ui': {
     'ui': {
         'static_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'static')),
         'static_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'static')),