mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-24 17:04:43 +00:00
Upgraded to rails 8.0.2, moved from dalli to solid cache, moved from delayed_job to solid queue, and add solid cable. deploy/rails-dev-run.sh no longer needs to chmod. Fixed finished_at callback for matches. Migrated from Devise to built in rails auth. Added view tests for the bracket page testing that all bout numbers render for all matches in each bracket type.
This commit is contained in:
@@ -4,37 +4,56 @@ require 'rails/all'
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(:default, Rails.env)
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module Wrestling
|
||||
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
config.time_zone = 'Eastern Time (US & Canada)'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
# config.i18n.default_locale = :de
|
||||
|
||||
#gzip assets
|
||||
|
||||
# Configure schema dumping for multiple databases
|
||||
config.active_record.schema_format = :ruby
|
||||
config.active_record.dump_schemas = :individual
|
||||
|
||||
# Fix deprecation warning for to_time in Rails 8.1
|
||||
config.active_support.to_time_preserves_timezone = :zone
|
||||
|
||||
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
||||
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
||||
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
||||
config.autoload_lib(ignore: %w[assets tasks])
|
||||
|
||||
# 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.eager_load_paths << Rails.root.join("extras")
|
||||
|
||||
# Restored custom settings from original application.rb
|
||||
|
||||
# gzip assets
|
||||
config.middleware.use Rack::Deflater
|
||||
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
|
||||
config.to_prepare do
|
||||
DeviseController.respond_to :html, :json
|
||||
end
|
||||
config.active_job.queue_adapter = :solid_queue
|
||||
|
||||
# Add all folders under app/services to the autoload paths
|
||||
config.autoload_paths += Dir[Rails.root.join('app', 'services', '**', '*')]
|
||||
# config.add_autoload_paths_to_load_path = false
|
||||
|
||||
config.active_support.cache_format_version = 7.2
|
||||
config.load_defaults 7.2
|
||||
end
|
||||
# Set cache format version to a value supported by Rails 8.0
|
||||
# Valid values are 7.0 or 7.1
|
||||
config.active_support.cache_format_version = 7.1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
require "bundler/setup" # Set up gems listed in the Gemfile.
|
||||
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
# Async adapter only works within the same process, so for manually triggering cable updates from a console,
|
||||
# and seeing results in the browser, you must do so from the web console (running inside the dev process),
|
||||
# not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
|
||||
# to make the web console appear.
|
||||
development:
|
||||
adapter: async
|
||||
adapter: solid_cable
|
||||
database: cable
|
||||
polling_interval: 0.1.seconds
|
||||
message_retention: 1.day
|
||||
|
||||
test:
|
||||
adapter: test
|
||||
|
||||
production:
|
||||
adapter: redis
|
||||
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
||||
channel_prefix: wrestling_production
|
||||
adapter: solid_cable
|
||||
database: cable
|
||||
polling_interval: 0.1.seconds
|
||||
message_retention: 1.day
|
||||
18
config/cache.yml
Normal file
18
config/cache.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
default: &default
|
||||
store_options:
|
||||
# Cap age of oldest cache entry to fulfill retention policies
|
||||
# max_age: <%= 60.days.to_i %>
|
||||
max_size: <%= 256.megabytes %>
|
||||
namespace: <%= Rails.env %>
|
||||
|
||||
development:
|
||||
database: cache
|
||||
<<: *default
|
||||
|
||||
test:
|
||||
database: cache
|
||||
<<: *default
|
||||
|
||||
production:
|
||||
database: cache
|
||||
<<: *default
|
||||
@@ -3,34 +3,84 @@
|
||||
#
|
||||
# Ensure the SQLite 3 gem is defined in your Gemfile
|
||||
# gem 'sqlite3'
|
||||
development:
|
||||
|
||||
default: &default
|
||||
adapter: sqlite3
|
||||
database: db/development.sqlite3
|
||||
pool: 5
|
||||
pool: <%=
|
||||
if ENV["DATABASE_POOL_SIZE"].present?
|
||||
ENV["DATABASE_POOL_SIZE"]
|
||||
else
|
||||
# Calculate based on max threads and estimated workers
|
||||
# Default to threads*workers or at least 5 connections
|
||||
max_threads = ENV.fetch("RAILS_MAX_THREADS", 12).to_i
|
||||
workers = ENV.fetch("WEB_CONCURRENCY", 2).to_i
|
||||
[max_threads * workers, 5].max
|
||||
end
|
||||
%>
|
||||
timeout: 5000
|
||||
|
||||
|
||||
#adapter: mysql
|
||||
#encoding: utf8
|
||||
#database: wrestlingtourney
|
||||
#pool: 5
|
||||
#username: root
|
||||
#password: password
|
||||
development:
|
||||
primary:
|
||||
<<: *default
|
||||
database: db/development.sqlite3
|
||||
queue:
|
||||
<<: *default
|
||||
database: db/development-queue.sqlite3
|
||||
cache:
|
||||
<<: *default
|
||||
database: db/development-cache.sqlite3
|
||||
cable:
|
||||
<<: *default
|
||||
database: db/development-cable.sqlite3
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: sqlite3
|
||||
database: db/test.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
primary:
|
||||
<<: *default
|
||||
database: db/test.sqlite3
|
||||
queue:
|
||||
<<: *default
|
||||
database: db/test-queue.sqlite3
|
||||
cache:
|
||||
<<: *default
|
||||
database: db/test-cache.sqlite3
|
||||
cable:
|
||||
<<: *default
|
||||
database: db/test-cable.sqlite3
|
||||
|
||||
production:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
database: <%= ENV['WRESTLINGDEV_DB_NAME'] %>
|
||||
username: <%= ENV['WRESTLINGDEV_DB_USR'] %>
|
||||
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
|
||||
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
|
||||
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
|
||||
primary:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
database: <%= ENV['WRESTLINGDEV_DB_NAME'] %>
|
||||
username: <%= ENV['WRESTLINGDEV_DB_USR'] %>
|
||||
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
|
||||
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
|
||||
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
|
||||
queue:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
database: <%= ENV['WRESTLINGDEV_DB_NAME'] %>-queue
|
||||
username: <%= ENV['WRESTLINGDEV_DB_USR'] %>
|
||||
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
|
||||
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
|
||||
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
|
||||
cache:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
database: <%= ENV['WRESTLINGDEV_DB_NAME'] %>-cache
|
||||
username: <%= ENV['WRESTLINGDEV_DB_USR'] %>
|
||||
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
|
||||
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
|
||||
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
|
||||
cable:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
database: <%= ENV['WRESTLINGDEV_DB_NAME'] %>-cable
|
||||
username: <%= ENV['WRESTLINGDEV_DB_USR'] %>
|
||||
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
|
||||
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
|
||||
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
|
||||
|
||||
|
||||
@@ -1,34 +1,101 @@
|
||||
Wrestling::Application.configure do
|
||||
require "active_support/core_ext/integer/time"
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# allow all hostnames
|
||||
config.hosts.clear
|
||||
config.hosts.clear
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
# Make code changes take effect immediately without server restart.
|
||||
config.enable_reloading = true
|
||||
|
||||
# Do not eager load code on boot.
|
||||
config.eager_load = false
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
# Show full error reports.
|
||||
config.consider_all_requests_local = true
|
||||
|
||||
# Enable server timing.
|
||||
config.server_timing = true
|
||||
|
||||
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
|
||||
# Run rails dev:cache to toggle Action Controller caching.
|
||||
if Rails.root.join("tmp/caching-dev.txt").exist?
|
||||
config.action_controller.perform_caching = true
|
||||
config.action_controller.enable_fragment_cache_logging = true
|
||||
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
|
||||
else
|
||||
config.action_controller.perform_caching = false
|
||||
end
|
||||
|
||||
# Replace the default in-process memory cache store with a durable alternative.
|
||||
# Using Solid Cache with MySQL
|
||||
config.cache_store = :solid_cache_store
|
||||
# Don't use connects_to here since it's configured via cache.yml
|
||||
# config.solid_cache.connects_to = { database: { writing: :cache } }
|
||||
|
||||
# Configure path for cache migrations
|
||||
config.paths["db/migrate"] << "db/cache/migrate"
|
||||
|
||||
# Configure Solid Queue as the ActiveJob queue adapter
|
||||
config.active_job.queue_adapter = :solid_queue
|
||||
# Don't use connects_to here since it's configured via queue.yml
|
||||
# config.solid_queue.connects_to = { database: { writing: :queue } }
|
||||
|
||||
# Configure path for queue migrations
|
||||
config.paths["db/migrate"] << "db/queue/migrate"
|
||||
|
||||
# Configure ActionCable to use its own database
|
||||
# Don't use connects_to here since it's configured via cable.yml
|
||||
# config.action_cable.connects_to = { database: { writing: :cable } }
|
||||
|
||||
# Configure path for cable migrations
|
||||
config.paths["db/migrate"] << "db/cable/migrate"
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Make template changes take effect immediately.
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Set localhost to be used by links generated in mailer templates.
|
||||
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
||||
|
||||
# Print deprecation notices to the Rails logger.
|
||||
config.active_support.deprecation = :log
|
||||
|
||||
# Raise an error on page load if there are pending migrations
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
# Highlight code that triggered database queries in logs.
|
||||
config.active_record.verbose_query_logs = true
|
||||
|
||||
# Append comments with runtime information tags to SQL queries in logs.
|
||||
config.active_record.query_log_tags_enabled = true
|
||||
|
||||
# Highlight code that enqueued background job in logs.
|
||||
config.active_job.verbose_enqueue_logs = true
|
||||
|
||||
# Raises error for missing translations.
|
||||
# config.i18n.raise_on_missing_translations = true
|
||||
|
||||
# Annotate rendered view with file names.
|
||||
config.action_view.annotate_rendered_view_with_filenames = true
|
||||
|
||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||
# config.action_cable.disable_request_forgery_protection = true
|
||||
|
||||
# Raise error when a before_action's only/except options reference missing actions.
|
||||
config.action_controller.raise_on_missing_callback_actions = true
|
||||
|
||||
# Restore Bullet configuration
|
||||
config.after_initialize do
|
||||
#Bullet.enable = true
|
||||
#Bullet.alert = true
|
||||
#Bullet.console = true
|
||||
#Bullet.bullet_logger = true
|
||||
#Bullet.enable = true
|
||||
#Bullet.alert = true
|
||||
#Bullet.console = true
|
||||
#Bullet.bullet_logger = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,78 +1,118 @@
|
||||
Wrestling::Application.configure do
|
||||
require "active_support/core_ext/integer/time"
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
config.enable_reloading = false
|
||||
|
||||
# Eager load code on boot. This eager loads most of Rails and
|
||||
# your application in memory, allowing both thread web servers
|
||||
# and those relying on copy on write to perform better.
|
||||
# Rake tasks automatically ignore this option for performance.
|
||||
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
|
||||
config.eager_load = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on.
|
||||
config.consider_all_requests_local = false
|
||||
# Full error reports are disabled.
|
||||
config.consider_all_requests_local = false
|
||||
|
||||
# Turn on fragment caching in view templates.
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
||||
# Add `rack-cache` to your Gemfile before enabling this.
|
||||
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
||||
# config.action_dispatch.rack_cache = true
|
||||
|
||||
# Specifies the header that your server uses for sending files.
|
||||
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Set to :debug to see everything in the log.
|
||||
config.log_level = :info
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
config.cache_store = :mem_cache_store,
|
||||
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
|
||||
{:username => ENV["MEMCACHIER_USERNAME"],
|
||||
:password => ENV["MEMCACHIER_PASSWORD"],
|
||||
:failover => true,
|
||||
:socket_timeout => 1.5,
|
||||
:socket_failure_delay => 0.2
|
||||
}
|
||||
# Cache assets for far-future expiry since they are all digest stamped.
|
||||
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
# config.asset_host = "http://assets.example.com"
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# config.assets.precompile += %w( search.js )
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
||||
# This is needed to prevent origin errors in login
|
||||
config.assume_ssl = ENV["REVERSE_PROXY_SSL_TERMINATION"] == "true"
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# Force SSL in production when RAILS_SSL_TERMINATION is true
|
||||
config.force_ssl = ENV["RAILS_SSL_TERMINATION"] == "true"
|
||||
|
||||
# Skip http-to-https redirect for the default health check endpoint.
|
||||
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
|
||||
|
||||
# Log to STDOUT with the current request id as a default log tag.
|
||||
config.log_tags = [ :request_id ]
|
||||
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
|
||||
|
||||
# Change to "debug" to log everything (including potentially personally-identifiable information!)
|
||||
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
||||
|
||||
# Prevent health checks from clogging up the logs.
|
||||
config.silence_healthcheck_path = "/up"
|
||||
|
||||
# Don't log any deprecations.
|
||||
config.active_support.report_deprecations = false
|
||||
|
||||
# Replace the default in-process memory cache store with a durable alternative.
|
||||
# Using Solid Cache with MySQL
|
||||
config.cache_store = :solid_cache_store
|
||||
# Don't use connects_to here since it's configured via cache.yml
|
||||
# config.solid_cache.connects_to = { database: { writing: :cache } }
|
||||
|
||||
# Configure path for cache migrations
|
||||
config.paths["db/migrate"] << "db/cache/migrate"
|
||||
|
||||
# Replace the default in-process and non-durable queuing backend for Active Job.
|
||||
config.active_job.queue_adapter = :solid_queue
|
||||
# Don't use connects_to here since it's configured via queue.yml
|
||||
# config.solid_queue.connects_to = { database: { writing: :queue } }
|
||||
|
||||
# Configure path for queue migrations
|
||||
config.paths["db/migrate"] << "db/queue/migrate"
|
||||
|
||||
# Configure ActionCable to use its own database
|
||||
# Don't use connects_to here since it's configured via cable.yml
|
||||
# config.action_cable.connects_to = { database: { writing: :cable } }
|
||||
|
||||
# Configure path for cable migrations
|
||||
config.paths["db/migrate"] << "db/cable/migrate"
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Set host to be used by links generated in mailer templates.
|
||||
config.action_mailer.default_url_options = { host: "wrestlingdev.com" }
|
||||
|
||||
# Restore custom SMTP settings
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => "smtp.gmail.com",
|
||||
:port => 587,
|
||||
:domain => "gmail.com",
|
||||
:user_name => ENV["WRESTLINGDEV_EMAIL"],
|
||||
:password => ENV["WRESTLINGDEV_EMAIL_PWD"],
|
||||
:authentication => :plain,
|
||||
:enable_starttls_auto => true
|
||||
}
|
||||
config.action_mailer.perform_deliveries = true
|
||||
# Login needs origin of email
|
||||
Rails.application.routes.default_url_options[:host] = 'https://wrestlingdev.com'
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation can not be found).
|
||||
# the I18n.default_locale when a translation cannot be found).
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners.
|
||||
config.active_support.deprecation = :notify
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
# Disable automatic flushing of the log to improve performance.
|
||||
# config.autoflush_log = false
|
||||
# Only use :id for inspections in production.
|
||||
config.active_record.attributes_for_inspect = [ :id ]
|
||||
|
||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
||||
config.log_formatter = ::Logger::Formatter.new
|
||||
|
||||
|
||||
#THESE ADDED BY ME TO GET RAILS 4 WORKING IN HEROKU
|
||||
config.cache_classes = true
|
||||
# Enable DNS rebinding protection and other `Host` header attacks.
|
||||
# config.hosts = [
|
||||
# "example.com", # Allow requests from example.com
|
||||
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
||||
# ]
|
||||
#
|
||||
# Skip DNS rebinding protection for the default health check endpoint.
|
||||
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
||||
|
||||
# Restore asset compilation settings
|
||||
config.public_file_server.enabled = true
|
||||
|
||||
## Using default asset pipeline sprockets
|
||||
@@ -80,24 +120,4 @@ Wrestling::Application.configure do
|
||||
config.assets.compile = true
|
||||
# Generate digests for assets URLs.
|
||||
config.assets.digest = true
|
||||
|
||||
#Added by me to force SSL in production on heroku
|
||||
if ENV["IS_HEROKU"] == "true"
|
||||
config.force_ssl = true
|
||||
end
|
||||
|
||||
#MAIL
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => "smtp.gmail.com",
|
||||
:port => 587,
|
||||
:domain => "gmail.com",
|
||||
:user_name => ENV["WRESTLINGDEV_EMAIL"],
|
||||
:password => ENV["WRESTLINGDEV_EMAIL_PWD"],
|
||||
:authentication => :plain,
|
||||
:enable_starttls_auto => true
|
||||
}
|
||||
config.action_mailer.perform_deliveries = true
|
||||
#Devise needs origin of email
|
||||
Rails.application.routes.default_url_options[:host] = 'https://wrestlingdev.com'
|
||||
|
||||
end
|
||||
|
||||
@@ -1,38 +1,77 @@
|
||||
Wrestling::Application.configure do
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
# While tests run files are not watched, reloading is not necessary.
|
||||
config.enable_reloading = false
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
# just for the purpose of running a single test. If you are using a tool that
|
||||
# preloads Rails for running tests, you may have to set it to true.
|
||||
config.eager_load = false
|
||||
# Eager loading loads your entire application. When running a single test locally,
|
||||
# this is usually not necessary, and can slow down your test suite. However, it's
|
||||
# recommended that you enable it in continuous integration systems to ensure eager
|
||||
# loading is working properly before deploying your code.
|
||||
config.eager_load = ENV["CI"].present?
|
||||
|
||||
# Configure static asset server for tests with Cache-Control for performance.
|
||||
config.public_file_server.enabled = true
|
||||
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
||||
# Configure public file server for tests with cache-control for performance.
|
||||
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
# Show full error reports.
|
||||
config.consider_all_requests_local = true
|
||||
|
||||
# Use solid cache store for testing
|
||||
config.cache_store = :solid_cache_store
|
||||
# Don't use connects_to here since it's configured via cache.yml
|
||||
# config.solid_cache.connects_to = { database: { writing: :cache } }
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
# Configure path for cache migrations
|
||||
config.paths["db/migrate"] << "db/cache/migrate"
|
||||
|
||||
# Configure ActiveJob to execute jobs immediately in tests
|
||||
# The test adapter will execute jobs inline immediately
|
||||
config.active_job.queue_adapter = :test
|
||||
|
||||
# Configure path for queue migrations
|
||||
config.paths["db/migrate"] << "db/queue/migrate"
|
||||
|
||||
# Configure ActionCable to use its own database for testing
|
||||
# Don't use connects_to here since it's configured via cable.yml
|
||||
# config.action_cable.connects_to = { database: { writing: :cable } }
|
||||
|
||||
# Configure path for cable migrations
|
||||
config.paths["db/migrate"] << "db/cable/migrate"
|
||||
|
||||
# Render exception templates for rescuable exceptions and raise for other exceptions.
|
||||
config.action_dispatch.show_exceptions = :rescuable
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Store uploaded files on the local file system in a temporary directory.
|
||||
config.active_storage.service = :test
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
# Set host to be used by links generated in mailer templates.
|
||||
config.action_mailer.default_url_options = { host: "example.com" }
|
||||
|
||||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
|
||||
|
||||
# Set test order to random as in previous configuration
|
||||
config.active_support.test_order = :random
|
||||
|
||||
# Raises error for missing translations.
|
||||
# config.i18n.raise_on_missing_translations = true
|
||||
|
||||
# Annotate rendered view with file names.
|
||||
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||
|
||||
# Raise error when a before_action's only/except options reference missing actions.
|
||||
config.action_controller.raise_on_missing_callback_actions = true
|
||||
end
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
Devise.setup do |config|
|
||||
# The secret key used by Devise. Devise uses this key to generate
|
||||
# random tokens. Changing this key will render invalid all existing
|
||||
# confirmation, reset password and unlock tokens in the database.
|
||||
if Rails.env.production?
|
||||
config.secret_key = ENV['WRESTLINGDEV_DEVISE_SECRET_KEY']
|
||||
else
|
||||
config.secret_key = "2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa"
|
||||
end
|
||||
|
||||
# ==> Mailer Configuration
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class
|
||||
# with default "from" parameter.
|
||||
config.mailer_sender = 'NOREPLY@wrestlingdev.com'
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
# config.mailer = 'Devise::Mailer'
|
||||
# ==> ORM configuration
|
||||
# Load and configure the ORM. Supports :active_record (default) and
|
||||
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
||||
# available as additional gems.
|
||||
require 'devise/orm/active_record'
|
||||
|
||||
# ==> Configuration for any authentication mechanism
|
||||
# Configure which keys are used when authenticating a user. The default is
|
||||
# just :email. You can configure it to use [:username, :subdomain], so for
|
||||
# authenticating a user, both parameters are required. Remember that those
|
||||
# parameters are used only when authenticating and not when retrieving from
|
||||
# session. If you need permissions, you should implement that in a before filter.
|
||||
# You can also supply a hash where the value is a boolean determining whether
|
||||
# or not authentication should be aborted when the value is not present.
|
||||
# config.authentication_keys = [ :email ]
|
||||
|
||||
# Configure parameters from the request object used for authentication. Each entry
|
||||
# given should be a request method and it will automatically be passed to the
|
||||
# find_for_authentication method and considered in your model lookup. For instance,
|
||||
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
||||
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
||||
# config.request_keys = []
|
||||
|
||||
# Configure which authentication keys should be case-insensitive.
|
||||
# These keys will be downcased upon creating or modifying a user and when used
|
||||
# to authenticate or find a user. Default is :email.
|
||||
config.case_insensitive_keys = [ :email ]
|
||||
|
||||
# Configure which authentication keys should have whitespace stripped.
|
||||
# These keys will have whitespace before and after removed upon creating or
|
||||
# modifying a user and when used to authenticate or find a user. Default is :email.
|
||||
config.strip_whitespace_keys = [ :email ]
|
||||
|
||||
# Tell if authentication through request.params is enabled. True by default.
|
||||
# It can be set to an array that will enable params authentication only for the
|
||||
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
||||
# enable it only for database (email + password) authentication.
|
||||
# config.params_authenticatable = true
|
||||
|
||||
# Tell if authentication through HTTP Auth is enabled. False by default.
|
||||
# It can be set to an array that will enable http authentication only for the
|
||||
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
||||
# enable it only for database authentication. The supported strategies are:
|
||||
# :database = Support basic authentication with authentication key + password
|
||||
# config.http_authenticatable = false
|
||||
|
||||
# If http headers should be returned for AJAX requests. True by default.
|
||||
# config.http_authenticatable_on_xhr = true
|
||||
|
||||
# The realm used in Http Basic Authentication. 'Application' by default.
|
||||
# config.http_authentication_realm = 'Application'
|
||||
|
||||
# It will change confirmation, password recovery and other workflows
|
||||
# to behave the same regardless if the e-mail provided was right or wrong.
|
||||
# Does not affect registerable.
|
||||
# config.paranoid = true
|
||||
|
||||
# By default Devise will store the user in session. You can skip storage for
|
||||
# particular strategies by setting this option.
|
||||
# Notice that if you are skipping storage for all authentication paths, you
|
||||
# may want to disable generating routes to Devise's sessions controller by
|
||||
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
||||
config.skip_session_storage = [:http_auth]
|
||||
|
||||
# By default, Devise cleans up the CSRF token on authentication to
|
||||
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
||||
# requests for sign in and sign up, you need to get a new CSRF token
|
||||
# from the server. You can disable this option at your own risk.
|
||||
# config.clean_up_csrf_token_on_authentication = true
|
||||
|
||||
# ==> Configuration for :database_authenticatable
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
||||
# using other encryptors, it sets how many times you want the password re-encrypted.
|
||||
#
|
||||
# Limiting the stretches to just one in testing will increase the performance of
|
||||
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
||||
# a value less than 10 in other environments.
|
||||
config.stretches = Rails.env.test? ? 1 : 10
|
||||
|
||||
# Setup a pepper to generate the encrypted password.
|
||||
# config.pepper = '84f10eecb0c3d505539ed5b410d6bf98c223257c43f2ad2a301c130286809fee566d6ba222f5792bc435d99e56d89303ec709de335b87eb2a10583b4864054a5'
|
||||
|
||||
# ==> Configuration for :confirmable
|
||||
# A period that the user is allowed to access the website even without
|
||||
# confirming his account. For instance, if set to 2.days, the user will be
|
||||
# able to access the website for two days without confirming his account,
|
||||
# access will be blocked just in the third day. Default is 0.days, meaning
|
||||
# the user cannot access the website without confirming his account.
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
|
||||
# A period that the user is allowed to confirm their account before their
|
||||
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
||||
# their account within 3 days after the mail was sent, but on the fourth day
|
||||
# their account can't be confirmed with the token any more.
|
||||
# Default is nil, meaning there is no restriction on how long a user can take
|
||||
# before confirming their account.
|
||||
# config.confirm_within = 3.days
|
||||
|
||||
# If true, requires any email changes to be confirmed (exactly the same way as
|
||||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field (see migrations). Until confirmed new email is stored in
|
||||
# unconfirmed email column, and copied to email column on successful confirmation.
|
||||
config.reconfirmable = true
|
||||
|
||||
# Defines which key will be used when confirming an account
|
||||
# config.confirmation_keys = [ :email ]
|
||||
|
||||
# ==> Configuration for :rememberable
|
||||
# The time the user will be remembered without asking for credentials again.
|
||||
# config.remember_for = 2.weeks
|
||||
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
# config.extend_remember_period = false
|
||||
|
||||
# Options to be passed to the created cookie. For instance, you can set
|
||||
# :secure => true in order to force SSL only cookies.
|
||||
# config.rememberable_options = {}
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length. Default is 8..128.
|
||||
config.password_length = 8..128
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
||||
|
||||
# ==> Configuration for :timeoutable
|
||||
# The time you want to timeout the user session without activity. After this
|
||||
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||
# config.timeout_in = 30.minutes
|
||||
|
||||
# If true, expires auth token on session timeout.
|
||||
# config.expire_auth_token_on_timeout = false
|
||||
|
||||
# ==> Configuration for :lockable
|
||||
# Defines which strategy will be used to lock an account.
|
||||
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
||||
# :none = No lock strategy. You should handle locking by yourself.
|
||||
# config.lock_strategy = :failed_attempts
|
||||
|
||||
# Defines which key will be used when locking and unlocking an account
|
||||
# config.unlock_keys = [ :email ]
|
||||
|
||||
# Defines which strategy will be used to unlock an account.
|
||||
# :email = Sends an unlock link to the user email
|
||||
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
||||
# :both = Enables both strategies
|
||||
# :none = No unlock strategy. You should handle unlocking by yourself.
|
||||
# config.unlock_strategy = :both
|
||||
|
||||
# Number of authentication tries before locking an account if lock_strategy
|
||||
# is failed attempts.
|
||||
# config.maximum_attempts = 20
|
||||
|
||||
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
||||
# config.unlock_in = 1.hour
|
||||
|
||||
# Warn on the last attempt before the account is locked.
|
||||
# config.last_attempt_warning = false
|
||||
|
||||
# ==> Configuration for :recoverable
|
||||
#
|
||||
# Defines which key will be used when recovering the password for an account
|
||||
# config.reset_password_keys = [ :email ]
|
||||
|
||||
# Time interval you can reset your password with a reset password key.
|
||||
# Don't put a too small interval or your users won't have the time to
|
||||
# change their passwords.
|
||||
config.reset_password_within = 6.hours
|
||||
|
||||
# ==> Configuration for :encryptable
|
||||
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
||||
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
||||
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
||||
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
||||
# REST_AUTH_SITE_KEY to pepper).
|
||||
#
|
||||
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
||||
# config.encryptor = :sha512
|
||||
|
||||
# ==> Scopes configuration
|
||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||
# are using only default views.
|
||||
# config.scoped_views = false
|
||||
|
||||
# Configure the default scope given to Warden. By default it's the first
|
||||
# devise role declared in your routes (usually :user).
|
||||
# config.default_scope = :user
|
||||
|
||||
# Set this configuration to false if you want /users/sign_out to sign out
|
||||
# only the current scope. By default, Devise signs out all scopes.
|
||||
# config.sign_out_all_scopes = true
|
||||
|
||||
# ==> Navigation configuration
|
||||
# Lists the formats that should be treated as navigational. Formats like
|
||||
# :html, should redirect to the sign in page when the user does not have
|
||||
# access, but formats like :xml or :json, should return 401.
|
||||
#
|
||||
# If you have any extra navigational formats, like :iphone or :mobile, you
|
||||
# should add them to the navigational formats lists.
|
||||
#
|
||||
# The "*/*" below is required to match Internet Explorer requests.
|
||||
# config.navigational_formats = ['*/*', :html]
|
||||
|
||||
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||
config.sign_out_via = :delete
|
||||
|
||||
# ==> OmniAuth
|
||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||
# up on your models and hooks.
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||
|
||||
# ==> Warden configuration
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
# change the failure app, you can configure them inside the config.warden block.
|
||||
#
|
||||
# config.warden do |manager|
|
||||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# end
|
||||
|
||||
# ==> Mountable engine configurations
|
||||
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||
# is mountable, there are some extra configurations to be taken into account.
|
||||
# The following options are available, assuming the engine is mounted as:
|
||||
#
|
||||
# mount MyEngine, at: '/my_engine'
|
||||
#
|
||||
# The router that invoked `devise_for`, in the example above, would be:
|
||||
# config.router_name = :my_engine
|
||||
#
|
||||
# When using omniauth, Devise cannot automatically set Omniauth path,
|
||||
# so you need to do it manually. For the users scope, it would be:
|
||||
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
||||
end
|
||||
@@ -4,5 +4,5 @@
|
||||
# Use this to limit dissemination of sensitive information.
|
||||
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
||||
Rails.application.config.filter_parameters += [
|
||||
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
|
||||
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
|
||||
]
|
||||
|
||||
66
config/initializers/solid_queue.rb
Normal file
66
config/initializers/solid_queue.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
# Configuration for Solid Queue in Rails 8
|
||||
# Documentation: https://github.com/rails/solid_queue
|
||||
|
||||
# Configure ActiveJob queue adapter based on environment
|
||||
if ! Rails.env.test?
|
||||
# In production and development, use solid_queue with async execution
|
||||
Rails.application.config.active_job.queue_adapter = :solid_queue
|
||||
|
||||
# Configure for regular async processing
|
||||
Rails.application.config.active_job.queue_adapter_options = {
|
||||
execution_mode: :async,
|
||||
logger: Rails.logger
|
||||
}
|
||||
else
|
||||
# In test, use inline adapter for simplicity
|
||||
Rails.application.config.active_job.queue_adapter = :inline
|
||||
end
|
||||
|
||||
# Register the custom attributes we want to track
|
||||
module SolidQueueConfig
|
||||
mattr_accessor :job_owner_tracking_enabled, default: true
|
||||
end
|
||||
|
||||
# Define ActiveJobExtensions - this should match what's already being used in ApplicationJob
|
||||
module ActiveJobExtensions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_accessor :job_owner_id, :job_owner_type
|
||||
end
|
||||
end
|
||||
|
||||
# Solid Queue adapter hooks to save job owner info to columns
|
||||
module SolidQueueAdapterExtensions
|
||||
def enqueue(job)
|
||||
job_data = job.serialize
|
||||
job_id = super
|
||||
|
||||
# Store job owner info after job is created
|
||||
if defined?(SolidQueue::Job) && job_data["job_owner_id"].present?
|
||||
Rails.logger.info("Setting job_owner for SolidQueue job #{job_id}: #{job_data["job_owner_id"]}, #{job_data["job_owner_type"]}")
|
||||
begin
|
||||
# Use execute_query for direct SQL to bypass any potential ActiveRecord issues
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE solid_queue_jobs SET job_owner_id = #{ActiveRecord::Base.connection.quote(job_data["job_owner_id"])}, " +
|
||||
"job_owner_type = #{ActiveRecord::Base.connection.quote(job_data["job_owner_type"])} " +
|
||||
"WHERE id = #{job_id}"
|
||||
)
|
||||
Rails.logger.info("Successfully updated job_owner info for job #{job_id}")
|
||||
rescue => e
|
||||
Rails.logger.error("Error updating job_owner info: #{e.message}")
|
||||
end
|
||||
end
|
||||
|
||||
job_id
|
||||
end
|
||||
end
|
||||
|
||||
# Apply extensions
|
||||
Rails.application.config.after_initialize do
|
||||
# Add extensions to ActiveJob::QueueAdapters::SolidQueueAdapter if defined
|
||||
if defined?(ActiveJob::QueueAdapters::SolidQueueAdapter)
|
||||
Rails.logger.info("Applying SolidQueueAdapterExtensions")
|
||||
ActiveJob::QueueAdapters::SolidQueueAdapter.prepend(SolidQueueAdapterExtensions)
|
||||
end
|
||||
end
|
||||
79
config/initializers/sqlite_config.rb
Normal file
79
config/initializers/sqlite_config.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
# Configure SQLite for better concurrency handling
|
||||
# This applies only in development mode with SQLite
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
if Rails.env.development? && ActiveRecord::Base.connection.adapter_name == "SQLite"
|
||||
connection = ActiveRecord::Base.connection
|
||||
|
||||
# 1. Configure SQLite behavior for better concurrency
|
||||
# Increase the busy timeout to 30 seconds (in milliseconds)
|
||||
connection.execute("PRAGMA busy_timeout = 30000;")
|
||||
|
||||
# Set journal mode to WAL for better concurrency
|
||||
connection.execute("PRAGMA journal_mode = WAL;")
|
||||
|
||||
# Configure synchronous mode for better performance
|
||||
connection.execute("PRAGMA synchronous = NORMAL;")
|
||||
|
||||
# Temp store in memory for better performance
|
||||
connection.execute("PRAGMA temp_store = MEMORY;")
|
||||
|
||||
# Use a larger cache size (8MB)
|
||||
connection.execute("PRAGMA cache_size = -8000;")
|
||||
|
||||
# Set locking mode to NORMAL
|
||||
connection.execute("PRAGMA locking_mode = NORMAL;")
|
||||
|
||||
# 2. Patch SQLite adapter with retry logic for development only
|
||||
if defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
|
||||
module SQLite3RetryLogic
|
||||
MAX_RETRIES = 5
|
||||
RETRY_DELAY = 0.5 # seconds
|
||||
RETRIABLE_EXCEPTIONS = [
|
||||
SQLite3::BusyException,
|
||||
ActiveRecord::StatementInvalid,
|
||||
ActiveRecord::StatementTimeout
|
||||
]
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
alias_method :original_execute, :execute
|
||||
alias_method :original_exec_query, :exec_query
|
||||
|
||||
def execute(*args)
|
||||
with_retries { original_execute(*args) }
|
||||
end
|
||||
|
||||
def exec_query(*args)
|
||||
with_retries { original_exec_query(*args) }
|
||||
end
|
||||
|
||||
private
|
||||
def with_retries
|
||||
retry_count = 0
|
||||
begin
|
||||
yield
|
||||
rescue *RETRIABLE_EXCEPTIONS => e
|
||||
if e.to_s.include?('database is locked') && retry_count < MAX_RETRIES
|
||||
retry_count += 1
|
||||
delay = RETRY_DELAY * retry_count
|
||||
Rails.logger.warn "SQLite database locked, retry #{retry_count}/#{MAX_RETRIES} after #{delay}s: #{e.message}"
|
||||
sleep(delay)
|
||||
retry
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch only in development
|
||||
ActiveRecord::ConnectionAdapters::SQLite3Adapter.include(SQLite3RetryLogic)
|
||||
Rails.logger.info "SQLite adapter patched with retry logic for database locks"
|
||||
end
|
||||
|
||||
Rails.logger.info "SQLite configured for improved concurrency in development"
|
||||
end
|
||||
end
|
||||
@@ -1,59 +0,0 @@
|
||||
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
en:
|
||||
devise:
|
||||
confirmations:
|
||||
confirmed: "Your account was successfully confirmed."
|
||||
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
|
||||
failure:
|
||||
already_authenticated: "You are already signed in."
|
||||
inactive: "Your account is not activated yet."
|
||||
invalid: "Invalid email or password."
|
||||
locked: "Your account is locked."
|
||||
last_attempt: "You have one more attempt before your account will be locked."
|
||||
not_found_in_database: "Invalid email or password."
|
||||
timeout: "Your session expired. Please sign in again to continue."
|
||||
unauthenticated: "You need to sign in or sign up before continuing."
|
||||
unconfirmed: "You have to confirm your account before continuing."
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: "Confirmation instructions"
|
||||
reset_password_instructions:
|
||||
subject: "Reset password instructions"
|
||||
unlock_instructions:
|
||||
subject: "Unlock Instructions"
|
||||
omniauth_callbacks:
|
||||
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
|
||||
success: "Successfully authenticated from %{kind} account."
|
||||
passwords:
|
||||
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
||||
send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes."
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
||||
updated: "Your password was changed successfully. You are now signed in."
|
||||
updated_not_active: "Your password was changed successfully."
|
||||
registrations:
|
||||
destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
|
||||
signed_up: "Welcome! You have signed up successfully."
|
||||
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
|
||||
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
|
||||
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
||||
updated: "You updated your account successfully."
|
||||
sessions:
|
||||
signed_in: "Signed in successfully."
|
||||
signed_out: "Signed out successfully."
|
||||
unlocks:
|
||||
send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
|
||||
send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
|
||||
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
|
||||
errors:
|
||||
messages:
|
||||
already_confirmed: "was already confirmed, please try signing in"
|
||||
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
|
||||
expired: "has expired, please request a new one"
|
||||
not_found: "not found"
|
||||
not_locked: "was not locked"
|
||||
not_saved:
|
||||
one: "1 error prohibited this %{resource} from being saved:"
|
||||
other: "%{count} errors prohibited this %{resource} from being saved:"
|
||||
@@ -1,13 +1,17 @@
|
||||
# This configuration file will be evaluated by Puma. The top-level methods that
|
||||
# are invoked here are part of Puma's configuration DSL. For more information
|
||||
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
|
||||
|
||||
#
|
||||
# Puma starts a configurable number of processes (workers) and each process
|
||||
# serves each request in a thread from an internal thread pool.
|
||||
#
|
||||
# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
|
||||
# should only set this value when you want to run 2 or more workers. The
|
||||
# default is already 1.
|
||||
#
|
||||
# The ideal number of threads per worker depends both on how much time the
|
||||
# application spends waiting for IO operations and on how much you wish to
|
||||
# to prioritize throughput over latency.
|
||||
# prioritize throughput over latency.
|
||||
#
|
||||
# As a rule of thumb, increasing the number of threads will increase how much
|
||||
# traffic a given process can handle (throughput), but due to CRuby's
|
||||
@@ -20,8 +24,56 @@
|
||||
# Any libraries that use a connection pool or another resource pool should
|
||||
# be configured to provide at least as many connections as the number of
|
||||
# threads. This includes Active Record's `pool` parameter in `database.yml`.
|
||||
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
|
||||
threads threads_count, threads_count
|
||||
|
||||
# Calculate available memory for Ruby process sizing (in MB)
|
||||
available_memory_mb = if RUBY_PLATFORM =~ /darwin/
|
||||
# Default to a reasonable amount on macOS where memory detection is difficult
|
||||
8192 # 8GB default
|
||||
else
|
||||
begin
|
||||
# Try to get memory from /proc/meminfo on Linux
|
||||
mem_total_kb = `grep MemTotal /proc/meminfo`.to_s.strip.split(/\s+/)[1].to_i
|
||||
mem_total_mb = mem_total_kb / 1024
|
||||
# If we couldn't detect memory, use a safe default
|
||||
mem_total_mb > 0 ? mem_total_mb : 4096
|
||||
rescue
|
||||
4096 # 4GB fallback if detection fails
|
||||
end
|
||||
end
|
||||
|
||||
# Calculate workers based on available CPUs and memory
|
||||
# Each worker uses ~300-500MB of RAM, so we scale based on available memory
|
||||
# If WEB_CONCURRENCY is set, use that value instead
|
||||
cpu_count = begin
|
||||
require 'etc'
|
||||
Etc.nprocessors
|
||||
rescue
|
||||
2 # Default to 2 if we can't detect
|
||||
end
|
||||
|
||||
# Default worker calculation:
|
||||
# - With ample memory: Use CPU count
|
||||
# - With limited memory: Use memory-based calculation with a min of 2 and max based on CPUs
|
||||
# This automatically adapts to the environment
|
||||
default_workers = if ENV["RAILS_ENV"] == "development"
|
||||
1 # Use 1 worker in development for simplicity
|
||||
else
|
||||
# Calculate based on available memory, assuming ~400MB per worker
|
||||
memory_based_workers = (available_memory_mb / 400).to_i
|
||||
# Ensure at least 2 workers for production (for zero-downtime restarts)
|
||||
# and cap at CPU count to avoid excessive context switching
|
||||
[memory_based_workers, 2].max
|
||||
end
|
||||
default_workers = [default_workers, cpu_count].min
|
||||
|
||||
workers_count = ENV.fetch("WEB_CONCURRENCY") { default_workers }
|
||||
|
||||
# Configure thread count for optimal throughput
|
||||
# More threads = better for IO-bound applications
|
||||
# Fewer threads = better for CPU-bound applications
|
||||
min_threads_count = ENV.fetch("RAILS_MIN_THREADS", 5)
|
||||
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 12)
|
||||
threads min_threads_count, max_threads_count
|
||||
|
||||
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
||||
port ENV.fetch("PORT", 3000)
|
||||
@@ -29,6 +81,28 @@ port ENV.fetch("PORT", 3000)
|
||||
# Allow puma to be restarted by `bin/rails restart` command.
|
||||
plugin :tmp_restart
|
||||
|
||||
# Run the Solid Queue supervisor inside of Puma for single-server deployments
|
||||
# Enable by default in development for convenience, can be disabled with SOLID_QUEUE_IN_PUMA=false
|
||||
if (Rails.env.development? && ENV["SOLID_QUEUE_IN_PUMA"] != "false") || ENV["SOLID_QUEUE_IN_PUMA"] == "true"
|
||||
plugin :solid_queue
|
||||
end
|
||||
|
||||
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
|
||||
# In other environments, only set the PID file if requested.
|
||||
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
|
||||
|
||||
# Set reasonable timeouts - these prevent hanging requests from consuming resources
|
||||
worker_timeout 60
|
||||
worker_boot_timeout 60
|
||||
|
||||
# Preload the application to reduce memory footprint in production
|
||||
preload_app! if ENV["RAILS_ENV"] == "production"
|
||||
|
||||
# When using preload_app, ensure that connections are properly handled
|
||||
on_worker_boot do
|
||||
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
||||
end
|
||||
|
||||
# Log the configuration
|
||||
puts "Puma starting with #{workers_count} worker(s), #{min_threads_count}-#{max_threads_count} threads per worker"
|
||||
puts "Available system resources: #{cpu_count} CPU(s), #{available_memory_mb}MB RAM"
|
||||
|
||||
21
config/queue.yml
Normal file
21
config/queue.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
default: &default
|
||||
dispatchers:
|
||||
- polling_interval: 1
|
||||
batch_size: 500
|
||||
workers:
|
||||
- queues: "*"
|
||||
threads: 3
|
||||
processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %>
|
||||
polling_interval: 0.1
|
||||
|
||||
development:
|
||||
database: queue
|
||||
<<: *default
|
||||
|
||||
test:
|
||||
database: queue
|
||||
<<: *default
|
||||
|
||||
production:
|
||||
database: queue
|
||||
<<: *default
|
||||
10
config/recurring.yml
Normal file
10
config/recurring.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
# production:
|
||||
# periodic_cleanup:
|
||||
# class: CleanSoftDeletedRecordsJob
|
||||
# queue: background
|
||||
# args: [ 1000, { batch_size: 500 } ]
|
||||
# schedule: every hour
|
||||
# periodic_command:
|
||||
# command: "SoftDeletedRecord.due.delete_all"
|
||||
# priority: 2
|
||||
# schedule: at 5am every day
|
||||
@@ -4,7 +4,18 @@ Wrestling::Application.routes.draw do
|
||||
|
||||
resources :matches
|
||||
|
||||
devise_for :users
|
||||
# Replace devise_for :users with custom routes
|
||||
get '/login', to: 'sessions#new'
|
||||
post '/login', to: 'sessions#create'
|
||||
delete '/logout', to: 'sessions#destroy'
|
||||
get '/signup', to: 'users#new'
|
||||
post '/signup', to: 'users#create'
|
||||
|
||||
# Password reset routes
|
||||
resources :password_resets, only: [:new, :create, :edit, :update]
|
||||
|
||||
# User resources for account management
|
||||
resources :users, only: [:show, :edit, :update]
|
||||
|
||||
resources :tournaments do
|
||||
resources :mat_assignment_rules, only: [:index, :new, :create, :edit, :update, :show, :destroy]
|
||||
@@ -78,8 +89,6 @@ Wrestling::Application.routes.draw do
|
||||
get "/api/index" => "api#index"
|
||||
post "/api/tournaments/new" => "newTournament"
|
||||
|
||||
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
|
||||
|
||||
get "/matches/:id/stat" => "matches#stat", :as => :stat_match_path
|
||||
|
||||
resources :tournaments do
|
||||
@@ -89,6 +98,7 @@ Wrestling::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
test:
|
||||
service: Disk
|
||||
root: <%= Rails.root.join("tmp/storage") %>
|
||||
|
||||
local:
|
||||
service: Disk
|
||||
root: <%= Rails.root.join("storage") %>
|
||||
|
||||
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
||||
# amazon:
|
||||
# service: S3
|
||||
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
||||
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
||||
# region: us-east-1
|
||||
# bucket: your_own_bucket
|
||||
|
||||
# Remember not to checkin your GCS keyfile to a repository
|
||||
# google:
|
||||
# service: GCS
|
||||
# project: your_project
|
||||
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
||||
# bucket: your_own_bucket
|
||||
|
||||
# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
||||
# microsoft:
|
||||
# service: AzureStorage
|
||||
# storage_account_name: your_account_name
|
||||
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
||||
# container: your_container_name
|
||||
|
||||
Reference in New Issue
Block a user