From 8439bef697427e12e9d0ee32526f35fe92beaf5e Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 21 Nov 2024 10:45:02 +0000 Subject: [PATCH 1/3] Use new rails-performance system stats --- Gemfile | 4 ++-- Gemfile.lock | 3 +++ config/initializers/rails_performance.rb | 8 ++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 175062e06..870831c9c 100644 --- a/Gemfile +++ b/Gemfile @@ -160,11 +160,11 @@ gem "omniauth_openid_connect", "~> 0.8.0" gem "sidekiq-cron", "~> 2.0" group :development, :production do + gem "sys-cpu", "~> 1.1" + gem "get_process_mem", "~> 1.0" gem "rails_performance", "~> 1.4" gem "redis-namespace" end gem "pghero", "~> 3.6" gem "pg_query", "~> 5.1" - -gem "get_process_mem", "~> 1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 1ec760964..a94b98c47 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -687,6 +687,8 @@ GEM attr_required (>= 0.0.5) faraday (~> 2.0) faraday-follow_redirects + sys-cpu (1.1.0) + ffi (~> 1.1) sys-filesystem (1.5.3) ffi (~> 1.1) terminal-table (3.0.2) @@ -826,6 +828,7 @@ DEPENDENCIES standard (~> 1.42.1) stopwords-filter2 string-similarity (~> 2.1) + sys-cpu (~> 1.1) sys-filesystem (~> 1.5) translation (~> 1.41) tzinfo-data diff --git a/config/initializers/rails_performance.rb b/config/initializers/rails_performance.rb index 69192fda9..c1200d576 100644 --- a/config/initializers/rails_performance.rb +++ b/config/initializers/rails_performance.rb @@ -17,12 +17,8 @@ # config.slow_requests_threshold = 500 # number of ms # store custom data for the request - config.custom_data_proc = proc do |env| - { - pid: Process.pid, - memory_usage: GetProcessMem.new.bytes - } - end + # config.custom_data_proc = proc do |env| + # end # config home button link config.home_link = "/" From 9c11b2c6b9b31205ef850420cdc0d8f1e0f471a3 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 25 Nov 2024 15:05:05 +0000 Subject: [PATCH 2/3] don't init rails performance during asset compilation --- config/initializers/rails_performance.rb | 2 +- docker/build.dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/initializers/rails_performance.rb b/config/initializers/rails_performance.rb index c1200d576..2ecb997b8 100644 --- a/config/initializers/rails_performance.rb +++ b/config/initializers/rails_performance.rb @@ -1,4 +1,4 @@ -if defined?(RailsPerformance) && !Rails.env.test? +if defined?(RailsPerformance) && !Rails.env.test? && ENV["RAILS_ASSETS_PRECOMPILE"].blank? RailsPerformance.setup do |config| config.redis = Redis::Namespace.new("#{Rails.env}-rails-performance", redis: Redis.new) config.duration = 4.hours diff --git a/docker/build.dockerfile b/docker/build.dockerfile index baeb80f5c..a6d0a1efa 100644 --- a/docker/build.dockerfile +++ b/docker/build.dockerfile @@ -27,4 +27,5 @@ RUN \ DATABASE_URL="nulldb://user:pass@localhost/db" \ SECRET_KEY_BASE="placeholder" \ RACK_ENV="production" \ + RAILS_ASSETS_PRECOMPILE=1 \ bundle exec rake assets:precompile From 471371c63a050ec4dd266b3d01f2ca424e2c942d Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 25 Nov 2024 15:39:37 +0000 Subject: [PATCH 3/3] disable rails-performance --- Gemfile | 4 ++-- Gemfile.lock | 9 --------- config/routes.rb | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 870831c9c..e91af7e67 100644 --- a/Gemfile +++ b/Gemfile @@ -162,8 +162,8 @@ gem "sidekiq-cron", "~> 2.0" group :development, :production do gem "sys-cpu", "~> 1.1" gem "get_process_mem", "~> 1.0" - gem "rails_performance", "~> 1.4" - gem "redis-namespace" + # gem "rails_performance", "~> 1.4" + # gem "redis-namespace" end gem "pghero", "~> 3.6" diff --git a/Gemfile.lock b/Gemfile.lock index a94b98c47..db451924a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,7 +148,6 @@ GEM msgpack (~> 1.2) brakeman (6.2.2) racc - browser (6.1.0) builder (3.3.0) bullet (8.0.0) activesupport (>= 3.0.0) @@ -535,10 +534,6 @@ GEM rails-settings-cached (2.9.5) activerecord (>= 5.0.0) railties (>= 5.0.0) - rails_performance (1.4.0) - browser - railties - redis railties (7.2.2) actionpack (= 7.2.2) activesupport (= 7.2.2) @@ -566,8 +561,6 @@ GEM redis-client (>= 0.22.0) redis-client (0.22.2) connection_pool - redis-namespace (1.11.0) - redis (>= 4) regexp_parser (2.9.2) reline (0.5.11) io-console (~> 0.5) @@ -803,10 +796,8 @@ DEPENDENCIES rails-controller-testing (~> 1.0) rails-i18n (~> 7.0) rails-settings-cached (~> 2.9) - rails_performance (~> 1.4) ransack (~> 4.2) redis (~> 5.3) - redis-namespace rolify (~> 6.0) rspec-rails rubocop-factory_bot diff --git a/config/routes.rb b/config/routes.rb index 87a2d090d..d5a876321 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,7 @@ resources :libraries, only: [:index] end mount Sidekiq::Web => "/admin/sidekiq" - mount RailsPerformance::Engine => "/admin/performance" unless Rails.env.test? + mount RailsPerformance::Engine => "/admin/performance" unless Rails.env.test? || ENV["RAILS_ASSETS_PRECOMPILE"].present? mount PgHero::Engine => "/admin/pghero" get "/activity" => "activity#index", :as => :activity end