reorganize initializers

This commit is contained in:
Dylan Knutson
2023-04-04 13:32:08 -07:00
parent f317aa273e
commit 230bd5757d
9 changed files with 55 additions and 53 deletions

View File

@@ -63,14 +63,19 @@ group :development do
gem "web-console"
gem "htmlbeautifier"
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
gem "rack-mini-profiler", require: ["enable_rails_patches", "rack-mini-profiler"]
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
gem "rufo", require: false
end
group :development, :staging do
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
gem "rack-mini-profiler", require: ["enable_rails_patches", "rack-mini-profiler"]
gem "memory_profiler"
gem "stackprof"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"

View File

@@ -175,6 +175,7 @@ GEM
net-smtp
marcel (1.0.2)
matrix (0.4.2)
memory_profiler (1.0.1)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
@@ -307,6 +308,7 @@ GEM
sprockets (>= 3.0.0)
sqlite3 (1.6.0)
mini_portile2 (~> 2.8.0)
stackprof (0.2.24)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
table_print (1.5.7)
@@ -364,6 +366,7 @@ DEPENDENCIES
influxdb-client
jbuilder
kaminari
memory_profiler
neighbor
nokogiri
pg
@@ -386,6 +389,7 @@ DEPENDENCIES
shakapacker
sprockets-rails
sqlite3 (~> 1.4)
stackprof
stimulus-rails
table_print
tailwindcss-rails (~> 2.0)

View File

@@ -9,6 +9,11 @@ class ApplicationController < ActionController::Base
@site_subtitle = "Furry Swiss Army Knife"
end
end
before_action do
if Rails.env.development? || Rails.env.staging?
Rack::MiniProfiler.authorize_request
end
end
API_TOKENS = {
"a4eb03ac-b33c-439c-9b51-a834d1c5cf48" => "dymk",

View File

@@ -15,34 +15,12 @@ module ReduxScraper
config.active_record.legacy_connection_handling = false
config.autoload_paths << config.root.join("app/lib")
# GoodJob configuration - applies to all environments (including test)
config.active_job.queue_adapter = :good_job
config.good_job.inline_execution_respects_schedule = true
config.good_job.active_record_parent_class = "ReduxApplicationRecord"
config.good_job.retry_on_unhandled_error = true
config.good_job.smaller_number_is_higher_priority = true
# job cleanup config - retain the last 24 hours of jobs
config.good_job.preserve_job_records = true
config.good_job.cleanup_preserved_jobs_before_seconds_ago = 1.day
config.good_job.cleanup_interval_jobs = 100_000
config.good_job.cleanup_interval_seconds = 4.hours
config.good_job.logger = Logger.new(STDOUT)
config.good_job.logger.level = :warn
if Rails.env.worker? || Rails.env.test?
config.good_job.execution_mode = :async
config.good_job.on_thread_error = ->(exception) { }
else
config.good_job.execution_mode = :external
end
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
config.time_zone = "Pacific Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.x.cookies.fa = ReduxScraper::Application.config_for("cookies/fa")
config.x.proxies = ReduxScraper::Application.config_for("proxies")
@@ -52,13 +30,5 @@ module ReduxScraper
config.x.proxy_name = proxy_name
config.x.proxy = Rails.application.config.x.proxies[proxy_name] || raise("no proxy config for '#{proxy_name}'")
config.x.proxy[:name] = proxy_name
# react-rails SSR
# config.same_bundle_for_client_and_server = true
# config.react.server_renderer = React::ServerRendering::BundleRenderer
# config.react.server_renderer_options = {
# files: ["server_rendering.js"], # files to load for prerendering
# replay_console: true, # if true, console.* will be replayed client-side
# }
end
end

View File

@@ -1,9 +1,5 @@
require "active_support/core_ext/integer/time"
Rack::MiniProfiler.config.position = "top-right"
Rack::MiniProfiler.config.skip_paths = [/\/api\/.+/]
Rack::MiniProfiler.config.disable_caching = false
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.web_console.development_only = false

View File

@@ -2,7 +2,6 @@ require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# config.react.server_renderer_extensions = ["jsx", "js", "tsx", "ts"]
# Code is not reloaded between requests.
config.cache_classes = true
@@ -23,7 +22,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
config.public_file_server.enabled = true
# Compress js / css assets
# config.assets.css_compressor = :sass

View File

@@ -1,10 +1,6 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# config.react.server_renderer_extensions = ["jsx", "js", "tsx", "ts"]
# config.react.variant = :production
config.hosts << "localhost"
config.hosts << "scraper.local"
@@ -17,6 +13,9 @@ Rails.application.configure do
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Enable server timing
config.server_timing = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
@@ -27,7 +26,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
config.public_file_server.enabled = true
# Compress js / css assets
# config.assets.css_compressor = :sass
@@ -89,15 +88,12 @@ Rails.application.configure do
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = logger
# $stdout.sync = true
# config.rails_semantic_logger.add_file_appender = false
# config.semantic_logger.add_appender(io: $stdout, formatter: config.rails_semantic_logger.format)
end
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = logger
$stdout.sync = true
config.rails_semantic_logger.add_file_appender = false
config.semantic_logger.add_appender(io: $stdout, formatter: config.rails_semantic_logger.format)
config.colorize_logging = true
config.log_tags = {

View File

@@ -0,0 +1,23 @@
Rails.application.configure do
# GoodJob configuration - applies to all environments (including test)
config.active_job.queue_adapter = :good_job
config.good_job.inline_execution_respects_schedule = true
config.good_job.active_record_parent_class = "ReduxApplicationRecord"
config.good_job.retry_on_unhandled_error = true
config.good_job.smaller_number_is_higher_priority = true
# job cleanup config - retain the last 24 hours of jobs
config.good_job.preserve_job_records = true
config.good_job.cleanup_preserved_jobs_before_seconds_ago = 1.day
config.good_job.cleanup_interval_jobs = 100_000
config.good_job.cleanup_interval_seconds = 4.hours
config.good_job.logger = Logger.new(STDOUT)
config.good_job.logger.level = :warn
if Rails.env.worker? || Rails.env.test?
config.good_job.execution_mode = :async
config.good_job.on_thread_error = ->(exception) { Rails.logger.error("GoodJob exception: #{exception}") }
else
config.good_job.execution_mode = :external
end
end

View File

@@ -0,0 +1,4 @@
if Rails.env.development? || Rails.env.staging?
Rack::MiniProfiler.config.position = "top-right"
Rack::MiniProfiler.config.disable_caching = false
end