diff --git a/config/application.rb b/config/application.rb index e56928354..907c8e6ca 100644 --- a/config/application.rb +++ b/config/application.rb @@ -50,6 +50,7 @@ ENV['MYSQL_PASSWORD'] ||= "" ENV['MYSQL_HOST'] ||= "mysql" ENV['MYSQL_PORT'] ||= "3306" +ENV['ES_REQUEST_TIMEOUT'] ||= "120" ENV['ES_HOST'] ||= "elasticsearch:9200" ENV['ES_NAME'] ||= "elasticsearch" ENV['ES_SCHEME'] ||= "http" @@ -71,7 +72,7 @@ class Application < Rails::Application config.paths.add Rails.root.join('app', 'graphql', 'mutations').to_s, eager_load: true config.paths.add Rails.root.join('app', 'graphql', 'connections').to_s, eager_load: true config.paths.add Rails.root.join('app', 'graphql', 'resolvers').to_s, eager_load: true - + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -84,7 +85,7 @@ class Application < Rails::Application # secret_key_base is not used by Rails API, as there are no sessions config.secret_key_base = "blipblapblup" - # enable datadog tracing here so that we can inject tracing + # enable datadog tracing here so that we can inject tracing # information into logs Datadog.configure do |c| c.tracer hostname: "datadog.local", enabled: Rails.env.production?, env: Rails.env @@ -116,7 +117,7 @@ class Application < Rails::Application correlation = Datadog.tracer.active_correlation exceptions = %w(controller action format id) - + { # Adds IDs as tags to log output dd: { @@ -158,7 +159,7 @@ class Application < Rails::Application end # use SQS based on environment, use "test" prefix for test system - if Rails.env == "stage" + if Rails.env == "stage" config.active_job.queue_name_prefix = ENV['ES_PREFIX'].present? ? "stage" : "test" else config.active_job.queue_name_prefix = Rails.env diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb index e38194ff2..3776ec62f 100644 --- a/config/initializers/elasticsearch.rb +++ b/config/initializers/elasticsearch.rb @@ -4,7 +4,12 @@ require 'faraday_middleware/aws_sigv4' if ENV['ES_HOST'] == "elasticsearch.test.datacite.org" || ENV['ES_HOST'] == "elasticsearch.datacite.org" - Elasticsearch::Model.client = Elasticsearch::Client.new(host: ENV['ES_HOST'], port: '80', scheme: 'http') do |f| + Elasticsearch::Model.client = Elasticsearch::Client.new( + host: ENV['ES_HOST'], + port: '80', + scheme: 'http', + request_timeout: ENV['ES_REQUEST_TIMEOUT'] + ) do |f| f.request :aws_sigv4, credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']), service: 'es',