mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 13:05:19 +02:00
Use Redis for ActiveJob and ActionCable (#2004)
* Use Redis for ActiveJob and ActionCable * Fix alwaysApply setting * Update queue names and weights * Tweak weights * Update job queues * Update docker setup guide * Remove deprecated upgrade columns from users table * Refactor Redis configuration for Sidekiq and caching in production environment * Add Sidekiq Sentry monitoring * queue naming fix * Clean up schema
This commit is contained in:
parent
a7db914005
commit
19cc63c8f4
75 changed files with 328 additions and 1684 deletions
|
@ -1,33 +0,0 @@
|
|||
Rails.application.configure do
|
||||
config.good_job.enable_cron = true
|
||||
|
||||
if ENV["UPGRADES_ENABLED"] == "true"
|
||||
config.good_job.cron = {
|
||||
auto_upgrade: {
|
||||
cron: "every 2 minutes",
|
||||
class: "AutoUpgradeJob",
|
||||
description: "Check for new versions of the app and upgrade if necessary"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
config.good_job.on_thread_error = ->(exception) { Rails.error.report(exception) }
|
||||
|
||||
# 7 dedicated queue threads + 5 catch-all threads + 3 for job listener, cron, executor = 15 threads allocated
|
||||
# `latency_low` queue for jobs ~30s
|
||||
# `latency_medium` queue for jobs ~1-2 min
|
||||
# `latency_high` queue for jobs ~5+ min
|
||||
config.good_job.queues = "latency_low:2;latency_low,latency_medium:3;latency_low,latency_medium,latency_high:2;*"
|
||||
|
||||
# Auth for jobs admin dashboard
|
||||
ActiveSupport.on_load(:good_job_application_controller) do
|
||||
before_action do
|
||||
raise ActionController::RoutingError.new("Not Found") unless current_user&.super_admin? || Rails.env.development?
|
||||
end
|
||||
|
||||
def current_user
|
||||
session = Session.find_by(id: cookies.signed[:session_token])
|
||||
session&.user
|
||||
end
|
||||
end
|
||||
end
|
9
config/initializers/sidekiq.rb
Normal file
9
config/initializers/sidekiq.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require "sidekiq/web"
|
||||
|
||||
Sidekiq::Web.use(Rack::Auth::Basic) do |username, password|
|
||||
configured_username = ::Digest::SHA256.hexdigest(ENV.fetch("SIDEKIQ_WEB_USERNAME", "maybe"))
|
||||
configured_password = ::Digest::SHA256.hexdigest(ENV.fetch("SIDEKIQ_WEB_PASSWORD", "maybe"))
|
||||
|
||||
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), configured_username) &&
|
||||
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), configured_password)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue