searxng_check.py 1019 B

12345678910111213141516171819202122232425262728293031323334
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. # lint: pylint
  3. """Implement some checks in the active installation
  4. """
  5. import os
  6. import sys
  7. import logging
  8. import warnings
  9. LOG_FORMAT_DEBUG = '%(levelname)-7s %(name)-30.30s: %(message)s'
  10. logging.basicConfig(level=logging.getLevelName('DEBUG'), format=LOG_FORMAT_DEBUG)
  11. os.environ['SEARXNG_DEBUG'] = '1'
  12. # from here on implement the checks of the installation
  13. import searx
  14. OLD_SETTING = '/etc/searx/settings.yml'
  15. if os.path.isfile(OLD_SETTING):
  16. msg = (
  17. '%s is no longer valid, move setting to %s' % (
  18. OLD_SETTING,
  19. os.environ.get('SEARXNG_SETTINGS_PATH', '/etc/searxng/settings.yml')
  20. ))
  21. warnings.warn(msg, DeprecationWarning)
  22. from searx.shared import redisdb
  23. from searx import get_setting
  24. if not redisdb.initialize():
  25. warnings.warn("can't connect to redis DB at: %s" % get_setting('redis.url'), RuntimeWarning, stacklevel=2)
  26. warnings.warn("--> no bot protection without redis DB", RuntimeWarning, stacklevel=2)