searxng_check.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. from pathlib import Path
  10. repo_root = Path(__file__).resolve().parent.parent
  11. LOG_FORMAT_DEBUG = '%(levelname)-7s %(name)-30.30s: %(message)s'
  12. logging.basicConfig(level=logging.getLevelName('DEBUG'), format=LOG_FORMAT_DEBUG)
  13. os.environ['SEARXNG_DEBUG'] = '1'
  14. # from here on implement the checks of the installation
  15. import searx
  16. OLD_SETTING = '/etc/searx/settings.yml'
  17. if os.path.isfile(OLD_SETTING):
  18. msg = (
  19. '%s is no longer valid, move setting to %s' % (
  20. OLD_SETTING,
  21. os.environ.get('SEARXNG_SETTINGS_PATH', '/etc/searxng/settings.yml')
  22. ))
  23. warnings.warn(msg, DeprecationWarning)
  24. OLD_BRAND_ENV = repo_root / 'utils' / 'brand.env'
  25. if os.path.isfile(OLD_BRAND_ENV):
  26. msg = ('%s is no longer needed, remove the file' % (OLD_BRAND_ENV))
  27. warnings.warn(msg, DeprecationWarning)
  28. from searx import redisdb, get_setting
  29. if not redisdb.initialize():
  30. warnings.warn("can't connect to redis DB at: %s" % get_setting('redis.url'), RuntimeWarning, stacklevel=2)
  31. warnings.warn("--> no bot protection without redis DB", RuntimeWarning, stacklevel=2)