searxng_check.py 1.2 KB

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