about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorJenkins <jenkins@jenkins.ninjawedding.org>2018-02-11 04:10:16 +0000
committerJenkins <jenkins@jenkins.ninjawedding.org>2018-02-11 04:10:16 +0000
commitefc9ffcb80b995ef8c8d95ab1d8cb0af8efc094d (patch)
tree6ce57e5980ba0279355f97893d21852caace0232 /config/initializers
parentb6159bcb0a20f3aabfb4d17ad60842b7aa81925c (diff)
parent718802a05dfb3211d758513daf6070ffa22751dd (diff)
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/chewy.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/config/initializers/chewy.rb b/config/initializers/chewy.rb
new file mode 100644
index 000000000..bef2746ec
--- /dev/null
+++ b/config/initializers/chewy.rb
@@ -0,0 +1,22 @@
+enabled         = ENV['ES_ENABLED'] == 'true'
+host            = ENV.fetch('ES_HOST') { 'localhost' }
+port            = ENV.fetch('ES_PORT') { 9200 }
+fallback_prefix = ENV.fetch('REDIS_NAMESPACE') { nil }
+prefix          = ENV.fetch('ES_PREFIX') { fallback_prefix }
+
+Chewy.settings = {
+  host: "#{host}:#{port}",
+  prefix: prefix,
+  enabled: enabled,
+  journal: false,
+}
+
+Chewy.root_strategy = enabled ? :sidekiq : :bypass
+
+module Chewy
+  class << self
+    def enabled?
+      settings[:enabled]
+    end
+  end
+end