Initialize Redis in searx/webapp.py

settings.yml:
* The default URL was unix:///usr/local/searxng-redis/run/redis.sock?db=0
* The default URL is now "false"

The default URL makes the log difficult to deal with:
if the admin didn't install a Redis instance, the logs record a false error.

It worked before because SearXNG initialized the Redis connection when the limiter started.

In this commit, SearXNG initializes Redis in searx/webapp.py
so various components can use Redis without taking care of the initialization step.
This commit is contained in:
Alexandre FLAMENT 2022-10-14 13:27:07 +00:00 committed by Alexandre Flament
parent fe419e355b
commit e92755d358
7 changed files with 36 additions and 24 deletions

View file

@ -295,7 +295,7 @@ In your instance, redis DB connector is configured at:
${redis_url}
"
if searxng.instance.exec python -c "from searx.shared import redisdb; redisdb.init() or exit(42)"; then
if searxng.instance.exec python -c "from searx.shared import redisdb; redisdb.initialize() or exit(42)"; then
info_msg "SearXNG instance is able to connect redis DB."
return
fi
@ -684,7 +684,7 @@ To install uWSGI use::
die 42 "SearXNG's uWSGI app not available"
fi
if ! searxng.instance.exec python -c "from searx.shared import redisdb; redisdb.init() or exit(42)"; then
if ! searxng.instance.exec python -c "from searx.shared import redisdb; redisdb.initialize() or exit(42)"; then
rst_para "\
The configured redis DB is not available: If your server is public to the
internet, you should setup a bot protection to block excessively bot queries.