Commit b4f8e281 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'rs-basic-config-files-ee' into 'master'

Wrap EE-only initializer settings in `Gitlab.ee` blocks

See merge request gitlab-org/gitlab-ee!14602
parents f4d2d082 d2b2791e
......@@ -6,6 +6,7 @@ Bundler.require(:default, Rails.env)
module Gitlab
class Application < Rails::Application
require_dependency Rails.root.join('lib/gitlab')
require_dependency Rails.root.join('lib/gitlab/redis/wrapper')
require_dependency Rails.root.join('lib/gitlab/redis/cache')
require_dependency Rails.root.join('lib/gitlab/redis/queues')
......
begin
# frozen_string_literal: true
Gitlab.ee do
begin
public_key_file = File.read(Rails.root.join(".license_encryption_key.pub"))
public_key = OpenSSL::PKey::RSA.new(public_key_file)
Gitlab::License.encryption_key = public_key
rescue
rescue
warn "WARNING: No valid license encryption key provided."
end
end
# Needed to run migration
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.data_source_exists?('licenses')
# Needed to run migration
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.data_source_exists?('licenses')
message = LicenseHelper.license_message(signed_in: true, is_admin: true, in_html: false)
if ::License.block_changes? && message.present?
warn "WARNING: #{message}"
end
end
end
......@@ -2,17 +2,18 @@
if defined?(Rails::Console)
# note that this will not print out when using `spring`
justify = 15
puts "-------------------------------------------------------------------------------------"
puts '-' * 80
puts " GitLab:".ljust(justify) + "#{Gitlab::VERSION} (#{Gitlab.revision})"
puts " GitLab Shell:".ljust(justify) + "#{Gitlab::VersionInfo.parse(Gitlab::Shell.new.version)}"
puts " #{Gitlab::Database.human_adapter_name}:".ljust(justify) + Gitlab::Database.version
# EE-specific start
Gitlab.ee do
if Gitlab::Geo.enabled?
puts " Geo enabled:".ljust(justify) + 'yes'
puts " Geo server:".ljust(justify) + EE::GeoHelper.current_node_human_status
end
# EE specific end
end
puts "-------------------------------------------------------------------------------------"
puts '-' * 80
end
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
require 'gitlab/current_settings'
Elasticsearch::Model::Response::Records.prepend GemExtensions::Elasticsearch::Model::Response::Records
Elasticsearch::Model::Adapter::Multiple::Records.prepend GemExtensions::Elasticsearch::Model::Adapter::Multiple::Records
Elasticsearch::Model::Indexing::InstanceMethods.prepend GemExtensions::Elasticsearch::Model::Indexing::InstanceMethods
Gitlab.ee do
Elasticsearch::Model::Response::Records.prepend GemExtensions::Elasticsearch::Model::Response::Records
Elasticsearch::Model::Adapter::Multiple::Records.prepend GemExtensions::Elasticsearch::Model::Adapter::Multiple::Records
Elasticsearch::Model::Indexing::InstanceMethods.prepend GemExtensions::Elasticsearch::Model::Indexing::InstanceMethods
module Elasticsearch
module Elasticsearch
module Model
module Client
# This mutex is only used to synchronize *creation* of a new client, so
......@@ -43,4 +46,5 @@ module Elasticsearch
end
end
end
end
end
if File.exist?(Rails.root.join('config/database_geo.yml'))
# frozen_string_literal: true
Gitlab.ee do
if File.exist?(Rails.root.join('config/database_geo.yml'))
Rails.application.configure do
config.geo_database = config_for(:database_geo)
end
end
end
begin
begin
if Gitlab::Geo.connected? && Gitlab::Geo.primary?
Gitlab::Geo.current_node&.update_clone_url!
end
rescue => e
rescue => e
warn "WARNING: Unable to check/update clone_url_prefix for Geo: #{e}"
end
end
......@@ -2,7 +2,9 @@ HealthCheck.setup do |config|
config.standard_checks = %w(database migrations cache)
config.full_checks = %w(database migrations cache)
Gitlab.ee do
config.add_custom_check('geo') do
Gitlab::Geo::HealthCheck.new.perform_checks
end
end
end
# frozen_string_literal: true
# We need to run this initializer after migrations are done so it doesn't fail on CI
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.data_source_exists?('licenses')
Gitlab.ee do
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.data_source_exists?('licenses')
if Gitlab::Database::LoadBalancing.enable?
Gitlab::Database.disable_prepared_statements
......@@ -17,4 +21,5 @@ if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.data_source_ex
end
end
end
end
......@@ -77,10 +77,6 @@ Sidekiq.configure_server do |config|
end
Sidekiq::Cron::Job.load_from_hash! cron_jobs
Gitlab::Mirror.configure_cron_job!
Gitlab::Geo.configure_cron_jobs!
Gitlab::SidekiqVersioning.install!
db_config = Gitlab::Database.config ||
......@@ -89,13 +85,18 @@ Sidekiq.configure_server do |config|
ActiveRecord::Base.establish_connection(db_config)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
# EE only
Gitlab.ee do
Gitlab::Mirror.configure_cron_job!
Gitlab::Geo.configure_cron_jobs!
if Gitlab::Geo.geo_database_configured?
Rails.configuration.geo_database['pool'] = Sidekiq.options[:concurrency]
Geo::TrackingBase.establish_connection(Rails.configuration.geo_database)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{Geo::TrackingBase.connection_pool.size} (Geo tracking database)")
end
end
# Avoid autoload issue such as 'Mail::Parsers::AddressStruct'
# https://github.com/mikel/mail/issues/912#issuecomment-214850355
......
if ENV['ENABLE_SIDEKIQ_CLUSTER']
# frozen_string_literal: true
if ENV['ENABLE_SIDEKIQ_CLUSTER'] && Gitlab.ee?
Thread.new do
Thread.current.abort_on_exception = true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment