2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
if Gitlab::Database::LoadBalancing.enable?
|
|
|
|
Gitlab::Database.disable_prepared_statements
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
Gitlab::Application.configure do |config|
|
|
|
|
config.middleware.use(Gitlab::Database::LoadBalancing::RackMiddleware)
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
Gitlab::Database::LoadBalancing.configure_proxy
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
# This needs to be executed after fork of clustered processes
|
|
|
|
Gitlab::Cluster::LifecycleEvents.on_worker_start do
|
|
|
|
# For Host-based LB, we need to re-connect as Rails discards connections on fork
|
|
|
|
Gitlab::Database::LoadBalancing.configure_proxy
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
# Service discovery must be started after configuring the proxy, as service
|
|
|
|
# discovery depends on this.
|
|
|
|
Gitlab::Database::LoadBalancing.start_service_discovery
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|