You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

  1. enabled = ENV['ES_ENABLED'] == 'true'
  2. host = ENV.fetch('ES_HOST') { 'localhost' }
  3. port = ENV.fetch('ES_PORT') { 9200 }
  4. user = ENV.fetch('ES_USER') { nil }
  5. password = ENV.fetch('ES_PASS') { nil }
  6. fallback_prefix = ENV.fetch('REDIS_NAMESPACE') { nil }
  7. prefix = ENV.fetch('ES_PREFIX') { fallback_prefix }
  8. Chewy.settings = {
  9. host: "#{host}:#{port}",
  10. prefix: prefix,
  11. enabled: enabled,
  12. journal: false,
  13. user: user,
  14. password: password,
  15. }
  16. # We use our own async strategy even outside the request-response
  17. # cycle, which takes care of checking if Elasticsearch is enabled
  18. # or not. However, mind that for the Rails console, the :urgent
  19. # strategy is set automatically with no way to override it.
  20. Chewy.request_strategy = :mastodon
  21. Chewy.use_after_commit_callbacks = false
  22. module Chewy
  23. class << self
  24. def enabled?
  25. settings[:enabled]
  26. end
  27. end
  28. end
  29. # Elasticsearch uses Faraday internally. Faraday interprets the
  30. # http_proxy env variable by default which leads to issues when
  31. # Mastodon is run with hidden services enabled, because
  32. # Elasticsearch is *not* supposed to be accessed through a proxy
  33. Faraday.ignore_env_proxy = true