From f798ddd4922d793d5e6ccb7c4111810d549ff4f4 Mon Sep 17 00:00:00 2001 From: Gaspard d'Hautefeuille Date: Wed, 9 Jul 2025 07:55:37 +0200 Subject: [mod] migrate from Redis to Valkey (#4795) This patch migrates from `redis==5.2.1` [1] to `valkey==6.1.0` [2]. The migration to valkey is necessary because the company behind Redis has decided to abandon the open source license. After experiencing a drop in user numbers, they now want to run it under a dual license again. But this move demonstrates once again how unreliable the company is and how it treats open source developers. To review first, read the docs:: $ make docs.live Follow the instructions to remove redis: - http://0.0.0.0:8000/admin/settings/settings_redis.html Config and install a local valkey DB: - http://0.0.0.0:8000/admin/settings/settings_valkey.html [1] https://pypi.org/project/redis/ [2] https://pypi.org/project/valkey/ Co-authored-by: HLFH Co-authored-by: Markus Heiser --- utils/searxng.sh | 133 ++++++++++++++++++++----------------------------------- 1 file changed, 48 insertions(+), 85 deletions(-) (limited to 'utils/searxng.sh') diff --git a/utils/searxng.sh b/utils/searxng.sh index 4ad2ef93f..663ca6d3d 100755 --- a/utils/searxng.sh +++ b/utils/searxng.sh @@ -9,6 +9,8 @@ SEARXNG_UWSGI_USE_SOCKET="${SEARXNG_UWSGI_USE_SOCKET:-true}" source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" # shellcheck source=utils/lib_redis.sh source "$(dirname "${BASH_SOURCE[0]}")/lib_redis.sh" +# shellcheck source=utils/lib_valkey.sh +source "$(dirname "${BASH_SOURCE[0]}")/lib_valkey.sh" # shellcheck source=utils/brand.sh source "${REPO_ROOT}/utils/brand.sh" @@ -119,8 +121,8 @@ usage() { # shellcheck disable=SC1117 cat < no way to get additional - # groups on fedora's tyrant mode. - # - # ERROR:searx.redisdb: [searxng (993)] can't connect redis DB ... - # ERROR:searx.redisdb: Error 13 connecting to unix socket: /usr/local/searxng-redis/run/redis.sock. Permission denied. - # ERROR:searx.plugins.limiter: init limiter DB failed!!! - # - # $ ps -aef | grep '/usr/sbin/uwsgi --ini searxng.ini' - # searxng 93 92 0 12:43 ? 00:00:00 /usr/sbin/uwsgi --ini searxng.ini - # searxng 186 93 0 12:44 ? 00:00:01 /usr/sbin/uwsgi --ini searxng.ini - # - # Additional groups: - # - # $ groups searxng - # searxng : searxng searxng-redis - # - # Here you can see that the additional "Groups" of PID 186 are unset - # (missing gid of searxng-redis) - # - # $ cat /proc/186/task/186/status - # ... - # Uid: 993 993 993 993 - # Gid: 993 993 993 993 - # FDSize: 128 - # Groups: - # ... - # - # [1] https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html#tyrant-mode-secure-multi-user-hosting - # [2] https://github.com/unbit/uwsgi/issues/2099 - # [3] https://github.com/unbit/uwsgi/pull/752 - - rst_para "\ -Fedora uses emperor-tyrant mode / in this mode we had a lot of trouble with -sockets and permissions of the vasals. We recommend to setup a redis DB -and using redis:// TCP protocol in the settings.yml configuration." - ;; - *) - if ask_yn "Do you want to install the redis DB now?" Yn; then - searxng.install.redis - uWSGI_restart "$SEARXNG_UWSGI_APP" - fi - ;; - esac + if ask_yn "Do you want to install the valkey DB now?" Yn; then + searxng.install.valkey + uWSGI_restart "$SEARXNG_UWSGI_APP" + fi } searxng.install.http.site() { @@ -380,16 +344,16 @@ searxng.install.http.site() { } searxng.remove.all() { - local redis_url + local valkey_url rst_title "De-Install SearXNG (service)" if ! ask_yn "Do you really want to deinstall SearXNG?"; then return fi - redis_url=$(searxng.instance.get_setting redis.url) - if ! [[ ${redis_url} = unix://${REDIS_HOME}/run/redis.sock* ]]; then - searxng.remove.redis + valkey_url=$(searxng.instance.get_setting valkey.url) + if ! [[ ${valkey_url} = unix://${VALKEY_HOME}/run/valkey.sock* ]]; then + searxng.remove.valkey fi searxng.remove.uwsgi @@ -642,19 +606,18 @@ searxng.remove.uwsgi() { uWSGI_remove_app "${SEARXNG_UWSGI_APP}" } -searxng.install.redis() { - rst_title "SearXNG (install redis)" - redis.build - redis.install - redis.addgrp "${SERVICE_USER}" -} - searxng.remove.redis() { rst_title "SearXNG (remove redis)" redis.rmgrp "${SERVICE_USER}" redis.remove } +searxng.install.valkey() { + rst_title "SearXNG (install valkey)" + valkey.install +} + + searxng.instance.localtest() { rst_title "Test SearXNG instance locally" section rst_para "Activate debug mode, start a minimal SearXNG "\ @@ -690,11 +653,11 @@ To install uWSGI use:: die 42 "SearXNG's uWSGI app not available" fi - if ! searxng.instance.exec python -c "from searx import redisdb; redisdb.initialize() or exit(42)"; then + if ! searxng.instance.exec python -c "from searx import valkeydb; valkeydb.initialize() or exit(42)"; then rst_para "\ -The configured redis DB is not available: If your server is public to the +The configured valkey DB is not available: If your server is public to the internet, you should setup a bot protection to block excessively bot queries. -Bot protection requires a redis DB. About bot protection visit the official +Bot protection requires a valkey DB. About bot protection visit the official SearXNG documentation and query for the word 'limiter'. " fi -- cgit v1.2.3