[fix] follow up of PR-1856
- `` url: false`` breaks with existing installations
e92755d358 (r89577339)
- PR-1856: https://github.com/searxng/searxng/pull/1856
- Comments from review: https://github.com/searxng/searxng/pull/1856#pullrequestreview-1176402810
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
e63457584b
commit
ec7c2b1a04
@ -305,7 +305,7 @@ In this example read/write access is given to the *searxng-redis* group. To get
|
|||||||
access rights to redis instance (the socket), your SearXNG (or even your
|
access rights to redis instance (the socket), your SearXNG (or even your
|
||||||
developer) account needs to be added to the *searxng-redis* group.
|
developer) account needs to be added to the *searxng-redis* group.
|
||||||
|
|
||||||
``url``
|
``url``: ``unix:///usr/local/searxng-redis/run/redis.sock?db=0``
|
||||||
URL to connect redis database, see `Redis.from_url(url)`_ & :ref:`redis db`::
|
URL to connect redis database, see `Redis.from_url(url)`_ & :ref:`redis db`::
|
||||||
|
|
||||||
redis://[[username]:[password]]@localhost:6379/0
|
redis://[[username]:[password]]@localhost:6379/0
|
||||||
@ -314,20 +314,14 @@ developer) account needs to be added to the *searxng-redis* group.
|
|||||||
|
|
||||||
.. admonition:: Tip for developers
|
.. admonition:: Tip for developers
|
||||||
|
|
||||||
To set up a local redis instance, first set the socket path of the Redis DB
|
To install a local redis instance that is connected by the default URL use
|
||||||
in your YAML setting:
|
the following commands::
|
||||||
|
|
||||||
.. code:: yaml
|
|
||||||
|
|
||||||
redis:
|
|
||||||
url: unix:///usr/local/searxng-redis/run/redis.sock?db=0
|
|
||||||
|
|
||||||
Then use the following commands to install the redis instance ::
|
|
||||||
|
|
||||||
$ ./manage redis.build
|
$ ./manage redis.build
|
||||||
$ sudo -H ./manage redis.install
|
$ sudo -H ./manage redis.install
|
||||||
$ sudo -H ./manage redis.addgrp "${USER}"
|
$ sudo -H ./manage redis.addgrp "${USER}"
|
||||||
# don't forget to logout & login to get member of group
|
|
||||||
|
Don't forget to logout & login to get member of group.
|
||||||
|
|
||||||
|
|
||||||
.. _settings outgoing:
|
.. _settings outgoing:
|
||||||
|
@ -76,9 +76,9 @@ server:
|
|||||||
X-Robots-Tag: noindex, nofollow
|
X-Robots-Tag: noindex, nofollow
|
||||||
Referrer-Policy: no-referrer
|
Referrer-Policy: no-referrer
|
||||||
|
|
||||||
redis:
|
# redis:
|
||||||
# https://redis-py.readthedocs.io/en/stable/connections.html#redis.client.Redis.from_url
|
# # https://redis-py.readthedocs.io/en/stable/connections.html#redis.client.Redis.from_url
|
||||||
url: false
|
# url: unix:///usr/local/searxng-redis/run/redis.sock?db=0
|
||||||
|
|
||||||
ui:
|
ui:
|
||||||
# Custom static path - leave it blank if you didn't change
|
# Custom static path - leave it blank if you didn't change
|
||||||
|
@ -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), 'unix:///usr/local/searxng-redis/run/redis.sock?db=0'),
|
||||||
},
|
},
|
||||||
'ui': {
|
'ui': {
|
||||||
'static_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'static')),
|
'static_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'static')),
|
||||||
|
@ -26,8 +26,8 @@ import redis
|
|||||||
from searx import get_setting
|
from searx import get_setting
|
||||||
|
|
||||||
|
|
||||||
OLD_REDIS_URL_DEFAULT_URL = 'unix:///usr/local/searxng-redis/run/redis.sock?db=0'
|
DEFAULT_URL = 'unix:///usr/local/searxng-redis/run/redis.sock?db=0'
|
||||||
"""This was the default Redis URL in settings.yml."""
|
"""This is the default Redis URL."""
|
||||||
|
|
||||||
_CLIENT = None
|
_CLIENT = None
|
||||||
logger = logging.getLogger('searx.shared.redisdb')
|
logger = logging.getLogger('searx.shared.redisdb')
|
||||||
@ -37,7 +37,7 @@ def client() -> redis.Redis:
|
|||||||
return _CLIENT
|
return _CLIENT
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
def init():
|
||||||
global _CLIENT # pylint: disable=global-statement
|
global _CLIENT # pylint: disable=global-statement
|
||||||
redis_url = get_setting('redis.url')
|
redis_url = get_setting('redis.url')
|
||||||
if not redis_url:
|
if not redis_url:
|
||||||
@ -62,7 +62,7 @@ def initialize():
|
|||||||
_CLIENT = None
|
_CLIENT = None
|
||||||
_pw = pwd.getpwuid(os.getuid())
|
_pw = pwd.getpwuid(os.getuid())
|
||||||
logger.exception("[%s (%s)] can't connect redis DB ...", _pw.pw_name, _pw.pw_uid)
|
logger.exception("[%s (%s)] can't connect redis DB ...", _pw.pw_name, _pw.pw_uid)
|
||||||
if redis_url == OLD_REDIS_URL_DEFAULT_URL and isinstance(e, redis.exceptions.ConnectionError):
|
if redis_url == DEFAULT_URL and isinstance(e, redis.exceptions.ConnectionError):
|
||||||
logger.info(
|
logger.info(
|
||||||
"You can safely ignore the above Redis error if you don't use Redis. "
|
"You can safely ignore the above Redis error if you don't use Redis. "
|
||||||
"You can remove this error by setting redis.url to false in your settings.yml."
|
"You can remove this error by setting redis.url to false in your settings.yml."
|
||||||
|
@ -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.shared import redisdb
|
||||||
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
|
||||||
@ -1385,7 +1385,7 @@ werkzeug_reloader = flask_run_development or (searx_debug and __name__ == "__mai
|
|||||||
if not werkzeug_reloader or (werkzeug_reloader and os.environ.get("WERKZEUG_RUN_MAIN") == "true"):
|
if not werkzeug_reloader or (werkzeug_reloader and os.environ.get("WERKZEUG_RUN_MAIN") == "true"):
|
||||||
locales_initialize()
|
locales_initialize()
|
||||||
_INFO_PAGES = infopage.InfoPageSet()
|
_INFO_PAGES = infopage.InfoPageSet()
|
||||||
redis_initialize()
|
redisdb.init()
|
||||||
plugin_initialize(app)
|
plugin_initialize(app)
|
||||||
search_initialize(enable_checker=True, check_network=True, enable_metrics=settings['general']['enable_metrics'])
|
search_initialize(enable_checker=True, check_network=True, enable_metrics=settings['general']['enable_metrics'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user