Skip to content

Commit

Permalink
Revert "Switch to Solid Queue + Mission Control" (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
northeastprince authored Dec 4, 2024
1 parent 370c7a4 commit bb734fc
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 322 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ gem "image_processing", ">= 1.2"
gem "active_storage_validations"

# Background jobs
gem "solid_queue"
gem "mission_control-jobs"
gem "sidekiq"
gem "sidekiq-cron"

# API
gem "jbuilder" # JSON templating
Expand Down
31 changes: 12 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ GEM
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.25.2)
mission_control-jobs (0.6.0)
actioncable (>= 7.1)
actionpack (>= 7.1)
activejob (>= 7.1)
activerecord (>= 7.1)
importmap-rails (>= 1.2.1)
irb (~> 1.13)
railties (>= 7.1)
stimulus-rails
turbo-rails
msgpack (1.7.2)
net-http (0.6.0)
uri
Expand Down Expand Up @@ -414,16 +404,19 @@ GEM
sass-embedded (1.81.0-x86_64-linux-gnu)
google-protobuf (~> 4.28)
securerandom (0.4.0)
sidekiq (7.3.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sidekiq-cron (1.12.0)
fugit (~> 1.8)
globalid (>= 1.0.1)
sidekiq (>= 6)
simple_form (5.3.1)
actionpack (>= 5.2)
activemodel (>= 5.2)
solid_queue (1.0.2)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
thor (~> 1.3.1)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -521,16 +514,16 @@ DEPENDENCIES
letter_opener_web
local_time
lograge
mission_control-jobs
pagy
premailer-rails
puma
rack-cors
rack-mini-profiler
rails!
redis
sidekiq
sidekiq-cron
simple_form
solid_queue
sprockets-rails
sqlite3
standard
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ _The thing that powers [hackathons.hackclub.com](https://hackathons.hackclub.com

## Contributing

This app is built with 🛤️ [Ruby on Rails](https://rubyonrails.org) (running [on the edge](https://shopify.engineering/living-on-the-edge-of-rails))
and uses 🥋 [Solid Queue](https://github.com/rails/solid_queue) for running background jobs.
This app is built with 🛤️ [Ruby on Rails](https://rubyonrails.org/) (running [on the edge](https://shopify.engineering/living-on-the-edge-of-rails))
and uses 🥋 [Sidekiq](https://sidekiq.org/)/[Redis](https://redis.io/) for running background jobs.

### Getting Started

Expand Down Expand Up @@ -65,7 +65,7 @@ brew install vips
- Heroku
- Redis (Heroku Data for Redis `premium0`)
- Hetzner
- Runs the Rails app and Solid Queue (3 vCPU, 4 GB)
- Runs the Rails app and Sidekiq (3 vCPU, 4 GB)
- Deployed via [Kamal](https://kamal-deploy.org)

### Kamal
Expand All @@ -92,12 +92,12 @@ Then, run the following locally on your computer:
bin/console prod
```

### Solid Queue
### Sidekiq

Solid Queue is used to process background jobs in production. In development, we use
Sidekiq is used to process background jobs in production. In development, we use
the good old default Active Job Async queue adapter.

To check up on jobs, visit `/admin/jobs` on the production site. You must
To check up on Sidekiq, visit `/admin/sidekiq` on the production site. You must
be logged in as an admin to access this page.

---
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/hackathons/digests_delivery_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Hackathons::DigestsDeliveryJob < ApplicationJob
sidekiq_options retry: 20 # up to 6.5 days

def perform
sent_digest_ids = []
current_subscribers.find_each do |subscriber|
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ servers:
jobs:
hosts:
- app-1.hackathons.hackclub.com
cmd: bundle exec rails solid_queue:start
cmd: bundle exec sidekiq
options:
memory: 1G
cpus: 1
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# Use a different cache store in production.
# config.cache_store = :mem_cache_store

config.active_job.queue_adapter = :solid_queue
config.active_job.queue_adapter = :sidekiq

# Send emails via SMTP using Amazon SES
config.action_mailer.delivery_method = :smtp
Expand Down
4 changes: 0 additions & 4 deletions config/initializers/action_mailer_concurrency.rb

This file was deleted.

18 changes: 18 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
redis = {
url: ENV["REDIS_URL"], timeout: 10.seconds,
ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE}
}

Sidekiq.configure_server do |config|
config.redis = redis

config.capsule("AWS SES") do |capsule| # avoid rate limits
Rails.configuration.action_mailer.deliver_later_queue_name = "SES"
capsule.queues = ["SES"]
capsule.concurrency = 1
end
end

Sidekiq.configure_client do |config|
config.redis = redis
end
15 changes: 0 additions & 15 deletions config/queue.yml

This file was deleted.

12 changes: 0 additions & 12 deletions config/recurring.yml

This file was deleted.

9 changes: 6 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require "sidekiq/web"
require "sidekiq/cron/web"

Rails.application.routes.draw do
root "hackathons#index"

Expand Down Expand Up @@ -25,10 +28,10 @@
resources :database_dumps, except: [:new, :show]

constraints Constraints::Admin do
namespace :admin do
mount MissionControl::Jobs::Engine => "jobs" if Rails.env.production?
mount Audits1984::Engine => "audits"
mount Sidekiq::Web => "/admin/sidekiq" if Rails.env.production?
mount Audits1984::Engine => "/admin/audits"

namespace :admin do
resources :hackathons, except: [:new, :create] do
scope module: :hackathons do
resource :hold, only: :create
Expand Down
8 changes: 8 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:verbose: false
:timeout: 25

:queues:
- critical
- SES
- default
- low
131 changes: 0 additions & 131 deletions db/migrate/20241125161900_create_solid_queue_tables.rb

This file was deleted.

Loading

0 comments on commit bb734fc

Please sign in to comment.