mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 12:10:11 +01:00
Merge pull request #1954 from dalf/fix.redis.init.2
[fix] follow up of PR-1856
This commit is contained in:
commit
9e9f57e48b
@ -294,7 +294,7 @@ Global Settings
|
|||||||
|
|
||||||
.. _Redis.from_url(url): https://redis-py.readthedocs.io/en/stable/connections.html#redis.client.Redis.from_url
|
.. _Redis.from_url(url): https://redis-py.readthedocs.io/en/stable/connections.html#redis.client.Redis.from_url
|
||||||
|
|
||||||
A redis DB can be connected by an URL, in :py:obj:`searx.shared.redisdb` you
|
A redis DB can be connected by an URL, in :py:obj:`searx.redisdb` you
|
||||||
will find a description to test your redis connection in SerXNG. When using
|
will find a description to test your redis connection in SerXNG. When using
|
||||||
sockets, don't forget to check the access rights on the socket::
|
sockets, don't forget to check the access rights on the socket::
|
||||||
|
|
||||||
|
@ -239,8 +239,8 @@ For example on Fedora (RHEL): If you try to install a redis DB with socket
|
|||||||
communication and you want to connect to it from the SearXNG uWSGI, you will see a
|
communication and you want to connect to it from the SearXNG uWSGI, you will see a
|
||||||
*Permission denied* in the log of your instance::
|
*Permission denied* in the log of your instance::
|
||||||
|
|
||||||
ERROR:searx.shared.redis: [searxng (993)] can't connect redis DB ...
|
ERROR:searx.redisdb: [searxng (993)] can't connect redis DB ...
|
||||||
ERROR:searx.shared.redis: Error 13 connecting to unix socket: /usr/local/searxng-redis/run/redis.sock. Permission denied.
|
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!!!
|
ERROR:searx.plugins.limiter: init limiter DB failed!!!
|
||||||
|
|
||||||
Even if your *searxng* user of the uWSGI process is added to additional groups
|
Even if your *searxng* user of the uWSGI process is added to additional groups
|
||||||
|
@ -132,5 +132,5 @@ to see if there are some left overs. In this example there exists a *old*
|
|||||||
INFO: [OK] (old) account 'filtron' does not exists
|
INFO: [OK] (old) account 'filtron' does not exists
|
||||||
INFO: [OK] (old) account 'morty' does not exists
|
INFO: [OK] (old) account 'morty' does not exists
|
||||||
...
|
...
|
||||||
INFO searx.shared : Use shared_simple implementation
|
INFO searx.redisdb : connecting to Redis db=0 path='/usr/local/searxng-redis/run/redis.sock'
|
||||||
INFO searx.shared.redis : connected redis DB --> default
|
INFO searx.redisdb : connected to Redis
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
Redis DB
|
Redis DB
|
||||||
========
|
========
|
||||||
|
|
||||||
.. automodule:: searx.shared.redisdb
|
.. automodule:: searx.redisdb
|
||||||
:members:
|
:members:
|
12
manage
12
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ Enable the plugin in ``settings.yml``:
|
|||||||
import re
|
import re
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
from searx.shared import redisdb
|
from searx import redisdb
|
||||||
from searx.redislib import incr_sliding_window
|
from searx.redislib import incr_sliding_window
|
||||||
|
|
||||||
name = "Request limiter"
|
name = "Request limiter"
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
This implementation uses the :ref:`settings redis` setup from ``settings.yml``.
|
This implementation uses the :ref:`settings redis` setup from ``settings.yml``.
|
||||||
A redis DB connect can be tested by::
|
A redis DB connect can be tested by::
|
||||||
|
|
||||||
>>> from searx.shared import redisdb
|
>>> from searx import redisdb
|
||||||
>>> redisdb.init()
|
>>> redisdb.initialize()
|
||||||
True
|
True
|
||||||
>>> db = redisdb.client()
|
>>> db = redisdb.client()
|
||||||
>>> db.set("foo", "bar")
|
>>> db.set("foo", "bar")
|
||||||
@ -30,7 +30,7 @@ OLD_REDIS_URL_DEFAULT_URL = 'unix:///usr/local/searxng-redis/run/redis.sock?db=0
|
|||||||
"""This was the default Redis URL in settings.yml."""
|
"""This was the default Redis URL in settings.yml."""
|
||||||
|
|
||||||
_CLIENT = None
|
_CLIENT = None
|
||||||
logger = logging.getLogger('searx.shared.redisdb')
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def client() -> redis.Redis:
|
def client() -> redis.Redis:
|
@ -14,7 +14,7 @@ from typing_extensions import TypedDict, Literal
|
|||||||
import redis.exceptions
|
import redis.exceptions
|
||||||
|
|
||||||
from searx import logger, settings, searx_debug
|
from searx import logger, settings, searx_debug
|
||||||
from searx.shared.redisdb import client as get_redis_client
|
from searx.redisdb import client as get_redis_client
|
||||||
from searx.exceptions import SearxSettingsException
|
from searx.exceptions import SearxSettingsException
|
||||||
from searx.search.processors import PROCESSORS
|
from searx.search.processors import PROCESSORS
|
||||||
from searx.search.checker import Checker
|
from searx.search.checker import Checker
|
||||||
|
@ -17,7 +17,7 @@ import time
|
|||||||
import importlib
|
import importlib
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from searx.shared.redisdb import client as get_redis_client
|
from searx.redisdb import client as get_redis_client
|
||||||
from searx.redislib import lua_script_storage
|
from searx.redislib import lua_script_storage
|
||||||
|
|
||||||
|
|
||||||
|
@ -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')),
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
# lint: pylint
|
|
||||||
"""Initialization of a *shared* storage.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from . import redisdb
|
|
@ -120,7 +120,7 @@ from searx.locales import (
|
|||||||
# renaming names from searx imports ...
|
# renaming names from searx imports ...
|
||||||
from searx.autocomplete import search_autocomplete, backends as autocomplete_backends
|
from searx.autocomplete import search_autocomplete, backends as autocomplete_backends
|
||||||
from searx.languages import language_codes as languages
|
from searx.languages import language_codes as languages
|
||||||
from searx.shared.redisdb import initialize as redis_initialize
|
from searx.redisdb import initialize as redis_initialize
|
||||||
from searx.search import SearchWithPlugins, initialize as search_initialize
|
from searx.search import SearchWithPlugins, initialize as search_initialize
|
||||||
from searx.network import stream as http_stream, set_context_network_name
|
from searx.network import stream as http_stream, set_context_network_name
|
||||||
from searx.search.checker import get_result as checker_get_result
|
from searx.search.checker import get_result as checker_get_result
|
||||||
|
@ -295,7 +295,7 @@ In your instance, redis DB connector is configured at:
|
|||||||
|
|
||||||
${redis_url}
|
${redis_url}
|
||||||
"
|
"
|
||||||
if searxng.instance.exec python -c "from searx.shared import redisdb; redisdb.initialize() or exit(42)"; then
|
if searxng.instance.exec python -c "from searx import redisdb; redisdb.initialize() or exit(42)"; then
|
||||||
info_msg "SearXNG instance is able to connect redis DB."
|
info_msg "SearXNG instance is able to connect redis DB."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -317,8 +317,8 @@ In your instance, redis DB connector is configured at:
|
|||||||
# fedora35 there is v2.0.20 installed --> no way to get additional
|
# fedora35 there is v2.0.20 installed --> no way to get additional
|
||||||
# groups on fedora's tyrant mode.
|
# groups on fedora's tyrant mode.
|
||||||
#
|
#
|
||||||
# ERROR:searx.shared.redis: [searxng (993)] can't connect redis DB ...
|
# ERROR:searx.redisdb: [searxng (993)] can't connect redis DB ...
|
||||||
# ERROR:searx.shared.redis: Error 13 connecting to unix socket: /usr/local/searxng-redis/run/redis.sock. Permission denied.
|
# 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!!!
|
# ERROR:searx.plugins.limiter: init limiter DB failed!!!
|
||||||
#
|
#
|
||||||
# $ ps -aef | grep '/usr/sbin/uwsgi --ini searxng.ini'
|
# $ ps -aef | grep '/usr/sbin/uwsgi --ini searxng.ini'
|
||||||
|
@ -26,8 +26,7 @@ if os.path.isfile(OLD_SETTING):
|
|||||||
))
|
))
|
||||||
warnings.warn(msg, DeprecationWarning)
|
warnings.warn(msg, DeprecationWarning)
|
||||||
|
|
||||||
from searx.shared import redisdb
|
from searx import redisdb, get_setting
|
||||||
from searx import get_setting
|
|
||||||
|
|
||||||
if not redisdb.initialize():
|
if not redisdb.initialize():
|
||||||
warnings.warn("can't connect to redis DB at: %s" % get_setting('redis.url'), RuntimeWarning, stacklevel=2)
|
warnings.warn("can't connect to redis DB at: %s" % get_setting('redis.url'), RuntimeWarning, stacklevel=2)
|
||||||
|
Loading…
Reference in New Issue
Block a user