1
0
Fork 0

Configure Elasticsearch

This commit is contained in:
Alex Kotov 2020-01-15 13:40:20 +05:00
parent 6846af8668
commit 3e8e161937
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 33 additions and 6 deletions

View File

@ -33,6 +33,11 @@ env:
- RAILS_CACHE_REDIS_DB=1
- RAILS_CACHE_REDIS_PASSWORD=
- ELASTICSEARCH_HOST=localhost
- ELASTICSEARCH_PORT=9200
- ELASTICSEARCH_USER=elastic
- ELASTICSEARCH_PASSWORD=changeme
before_install:
- wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
- sudo tar -xvzf geckodriver*

View File

@ -2,15 +2,17 @@
# Be sure to restart your server when you modify this file.
conf = Rails.application.settings :elasticsearch
Elasticsearch::Model.client = Elasticsearch::Client.new(
scheme: :http,
host: '127.0.0.1',
port: 9200,
user: 'elastic',
password: 'changeme',
scheme: conf[:ssl] ? :https : :http,
host: String(conf[:host]),
port: Integer(conf[:port]),
user: String(conf[:user]),
password: String(conf[:password]),
transport_options: {
request: { timeout: 5 },
ssl: { ca_file: nil },
ssl: { ca_file: conf.dig(:ssl_params, :ca_file) },
},
)

View File

@ -0,0 +1,20 @@
default: &default
host: <%= ENV.fetch('ELASTICSEARCH_HOST') { 'localhost' } %>
port: <%= ENV.fetch('ELASTICSEARCH_PORT') { 9200 } %>
user: <%= ENV.fetch('ELASTICSEARCH_USER') { 'elastic' } %>
password: <%= ENV.fetch('ELASTICSEARCH_PASSWORD') { 'changeme' } %>
ssl: false
ssl_params:
ca_file: null
development:
<<: *default
test:
<<: *default
staging:
<<: *default
production:
<<: *default