Load Geo DB only when Geo database config file exist

parent 80f6662a
...@@ -158,8 +158,5 @@ module Gitlab ...@@ -158,8 +158,5 @@ module Gitlab
config.generators do |g| config.generators do |g|
g.factory_girl false g.factory_girl false
end end
# This is needed for GitLab Geo
config.assets.initialize_on_precompile = false
end end
end end
if Gitlab::Geo.secondary? if File.exist?(Rails.root.join('config/database_geo.yml'))
Rails.application.configure do Rails.application.configure do
config.geo_database = config_for(:database_geo) config.geo_database = config_for(:database_geo)
end end
......
...@@ -2,9 +2,7 @@ HealthCheck.setup do |config| ...@@ -2,9 +2,7 @@ HealthCheck.setup do |config|
config.standard_checks = %w(database migrations cache) config.standard_checks = %w(database migrations cache)
config.full_checks = %w(database migrations cache) config.full_checks = %w(database migrations cache)
if Gitlab::Geo.secondary?
config.add_custom_check('geo') do config.add_custom_check('geo') do
Gitlab::Geo::HealthCheck.perform_checks Gitlab::Geo::HealthCheck.perform_checks
end end
end
end end
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
end end
def self.enabled? def self.enabled?
self.cache_value(:geo_node_enabled) { self.connected_to_primary_db? && GeoNode.exists? } self.cache_value(:geo_node_enabled) { GeoNode.exists? }
end end
def self.license_allows? def self.license_allows?
...@@ -80,10 +80,5 @@ module Gitlab ...@@ -80,10 +80,5 @@ module Gitlab
# urlsafe_base64 may return a string of size * 4/3 # urlsafe_base64 may return a string of size * 4/3
SecureRandom.urlsafe_base64(size)[0, size] SecureRandom.urlsafe_base64(size)[0, size]
end end
def self.connected_to_primary_db?
ActiveRecord::Base.connection.active? &&
ActiveRecord::Base.connection.table_exists?(GeoNode.table_name)
end
end end
end end
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