diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 21:08:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 21:08:10 +0300 |
commit | 175b4fa261259ab0d033482d10bb4159fee8e538 (patch) | |
tree | e1f1dba5e41177f11ffded5a505e0e7f692b8df5 /config | |
parent | 4eea104c69e59f6fa53c7bc15b986c69f29b60c8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 3 | ||||
-rw-r--r-- | config/environments/development.rb | 2 | ||||
-rw-r--r-- | config/environments/production.rb | 2 | ||||
-rw-r--r-- | config/initializers/0_runtime_identify.rb | 13 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 2 | ||||
-rw-r--r-- | config/initializers/7_prometheus_metrics.rb | 12 | ||||
-rw-r--r-- | config/initializers/active_record_lifecycle.rb | 2 | ||||
-rw-r--r-- | config/initializers/cluster_events_before_phased_restart.rb | 6 | ||||
-rw-r--r-- | config/initializers/database_config.rb | 2 | ||||
-rw-r--r-- | config/initializers/lograge.rb | 2 | ||||
-rw-r--r-- | config/initializers/rack_timeout.rb | 2 | ||||
-rw-r--r-- | config/initializers/tracing.rb | 2 | ||||
-rw-r--r-- | config/initializers/validate_puma.rb | 2 |
13 files changed, 32 insertions, 20 deletions
diff --git a/config/application.rb b/config/application.rb index cad5c8bbe76..28c1eba920b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,6 +22,7 @@ module Gitlab require_dependency Rails.root.join('lib/gitlab/current_settings') require_dependency Rails.root.join('lib/gitlab/middleware/read_only') require_dependency Rails.root.join('lib/gitlab/middleware/basic_health_check') + require_dependency Rails.root.join('lib/gitlab/runtime') # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -255,7 +256,7 @@ module Gitlab caching_config_hash[:compress] = false caching_config_hash[:namespace] = Gitlab::Redis::Cache::CACHE_NAMESPACE caching_config_hash[:expires_in] = 2.weeks # Cache should not grow forever - if Sidekiq.server? || defined?(::Puma) # threaded context + if Gitlab::Runtime.multi_threaded? caching_config_hash[:pool_size] = Gitlab::Redis::Cache.pool_size caching_config_hash[:pool_timeout] = 1 end diff --git a/config/environments/development.rb b/config/environments/development.rb index 2939e13ef94..dc804197fef 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -46,7 +46,7 @@ Rails.application.configure do # Do not log asset requests config.assets.quiet = true - config.allow_concurrency = defined?(::Puma) + config.allow_concurrency = Gitlab::Runtime.multi_threaded? # BetterErrors live shell (REPL) on every stack frame BetterErrors::Middleware.allow_ip!("127.0.0.1/0") diff --git a/config/environments/production.rb b/config/environments/production.rb index 09bcf49a9a5..7ec18547b2f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -75,5 +75,5 @@ Rails.application.configure do config.eager_load = true - config.allow_concurrency = defined?(::Puma) + config.allow_concurrency = Gitlab::Runtime.multi_threaded? end diff --git a/config/initializers/0_runtime_identify.rb b/config/initializers/0_runtime_identify.rb new file mode 100644 index 00000000000..2b5d08102eb --- /dev/null +++ b/config/initializers/0_runtime_identify.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +begin + Gitlab::AppLogger.info("Runtime: #{Gitlab::Runtime.name}") +rescue => e + message = <<-NOTICE + \n!! RUNTIME IDENTIFICATION FAILED: #{e} + Runtime based configuration settings may not work properly. + If you continue to see this error, please file an issue via + https://gitlab.com/gitlab-org/gitlab/issues/new + NOTICE + Gitlab::AppLogger.error(message) +end diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 8e4aa5701b4..bb0c4696eff 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -364,7 +364,7 @@ Gitlab.ee do # To ensure acceptable performance we only allow feature to be used with # multithreaded web-server Puma. This will be removed once download logic is moved # to GitLab workhorse - Settings.dependency_proxy['enabled'] = false unless defined?(::Puma) + Settings.dependency_proxy['enabled'] = false unless Gitlab::Runtime.puma? end # diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index d40049970c1..513f4d9e6ad 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -4,11 +4,11 @@ require 'prometheus/client' def prometheus_default_multiproc_dir return unless Rails.env.development? || Rails.env.test? - if Sidekiq.server? + if Gitlab::Runtime.sidekiq? Rails.root.join('tmp/prometheus_multiproc_dir/sidekiq') - elsif defined?(Unicorn::Worker) + elsif Gitlab::Runtime.unicorn? Rails.root.join('tmp/prometheus_multiproc_dir/unicorn') - elsif defined?(::Puma) + elsif Gitlab::Runtime.puma? Rails.root.join('tmp/prometheus_multiproc_dir/puma') else Rails.root.join('tmp/prometheus_multiproc_dir') @@ -55,9 +55,9 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? Gitlab::Cluster::LifecycleEvents.on_master_start do ::Prometheus::Client.reinitialize_on_pid_change(force: true) - if defined?(::Unicorn) + if Gitlab::Runtime.unicorn? Gitlab::Metrics::Samplers::UnicornSampler.instance(Settings.monitoring.unicorn_sampler_interval).start - elsif defined?(::Puma) + elsif Gitlab::Runtime.puma? Gitlab::Metrics::Samplers::PumaSampler.instance(Settings.monitoring.puma_sampler_interval).start end @@ -65,7 +65,7 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? end end -if defined?(::Unicorn) || defined?(::Puma) +if Gitlab::Runtime.app_server? Gitlab::Cluster::LifecycleEvents.on_master_start do Gitlab::Metrics::Exporter::WebExporter.instance.start end diff --git a/config/initializers/active_record_lifecycle.rb b/config/initializers/active_record_lifecycle.rb index 61f1d299960..2cf0f0439a9 100644 --- a/config/initializers/active_record_lifecycle.rb +++ b/config/initializers/active_record_lifecycle.rb @@ -2,7 +2,7 @@ # Don't handle sidekiq configuration as it # has its own special active record configuration here -if defined?(ActiveRecord::Base) && !Sidekiq.server? +if defined?(ActiveRecord::Base) && !Gitlab::Runtime.sidekiq? Gitlab::Cluster::LifecycleEvents.on_worker_start do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.establish_connection diff --git a/config/initializers/cluster_events_before_phased_restart.rb b/config/initializers/cluster_events_before_phased_restart.rb index cbb1dd1a53a..aae5470d6ae 100644 --- a/config/initializers/cluster_events_before_phased_restart.rb +++ b/config/initializers/cluster_events_before_phased_restart.rb @@ -5,10 +5,8 @@ # # Follow-up the issue: https://gitlab.com/gitlab-org/gitlab/issues/34107 -if defined?(::Puma) +if Gitlab::Runtime.puma? Puma::Cluster.prepend(::Gitlab::Cluster::Mixins::PumaCluster) -end - -if defined?(::Unicorn::HttpServer) +elsif Gitlab::Runtime.unicorn? Unicorn::HttpServer.prepend(::Gitlab::Cluster::Mixins::UnicornHttpServer) end diff --git a/config/initializers/database_config.rb b/config/initializers/database_config.rb index d8c2821066b..509f04c9b02 100644 --- a/config/initializers/database_config.rb +++ b/config/initializers/database_config.rb @@ -2,7 +2,7 @@ # when running on puma, scale connection pool size with the number # of threads per worker process -if defined?(::Puma) +if Gitlab::Runtime.puma? db_config = Gitlab::Database.config || Rails.application.config.database_configuration[Rails.env] puma_options = Puma.cli_config.options diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index a8207862739..0acbe6a9258 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -1,5 +1,5 @@ # Only use Lograge for Rails -unless Sidekiq.server? +unless Gitlab::Runtime.sidekiq? filename = File.join(Rails.root, 'log', "#{Rails.env}_json.log") Rails.application.configure do diff --git a/config/initializers/rack_timeout.rb b/config/initializers/rack_timeout.rb index 246cf3482a4..1f1264de208 100644 --- a/config/initializers/rack_timeout.rb +++ b/config/initializers/rack_timeout.rb @@ -9,7 +9,7 @@ # and it's used only as the last resort. In such case this termination is # logged and we should fix the potential timeout issue in the code itself. -if defined?(::Puma) && !Rails.env.test? +if Gitlab::Runtime.puma? && !Rails.env.test? require 'rack/timeout/base' Gitlab::Application.configure do |config| diff --git a/config/initializers/tracing.rb b/config/initializers/tracing.rb index 5b55a06692e..0ae57021fcf 100644 --- a/config/initializers/tracing.rb +++ b/config/initializers/tracing.rb @@ -13,7 +13,7 @@ if Labkit::Tracing.enabled? end # Instrument Sidekiq server calls when running Sidekiq server - if Sidekiq.server? + if Gitlab::Runtime.sidekiq? Sidekiq.configure_server do |config| config.server_middleware do |chain| chain.add Labkit::Tracing::Sidekiq::ServerMiddleware diff --git a/config/initializers/validate_puma.rb b/config/initializers/validate_puma.rb index 64bd6e7bbc1..5abcfbfe6be 100644 --- a/config/initializers/validate_puma.rb +++ b/config/initializers/validate_puma.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -if defined?(::Puma) && ::Puma.cli_config.options[:workers].to_i.zero? +if Gitlab::Runtime.puma? && ::Puma.cli_config.options[:workers].to_i.zero? raise 'Puma is only supported in Cluster-mode: workers > 0' end |