Skip to content

Commit cf976b0

Browse files
authored
Add Solid Queue alongside Solid Cache (rails#52804)
* Add Solid Queue alongside Solid Cache
1 parent d437ae3 commit cf976b0

File tree

12 files changed

+67
-9
lines changed

12 files changed

+67
-9
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ gem "importmap-rails", ">= 1.2.3"
2222
gem "tailwindcss-rails"
2323
gem "dartsass-rails"
2424
gem "solid_cache"
25+
gem "solid_queue"
2526
gem "kamal", require: false
2627
gem "thruster", require: false
2728
# require: false so bcrypt is loaded only when has_secure_password is used.

Gemfile.lock

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ GEM
212212
drb (2.2.1)
213213
ed25519 (1.3.0)
214214
erubi (1.13.0)
215-
et-orbi (1.2.7)
215+
et-orbi (1.2.11)
216216
tzinfo
217217
event_emitter (0.2.6)
218218
execjs (2.9.1)
@@ -244,8 +244,8 @@ GEM
244244
ffi (1.17.0)
245245
ffi (1.17.0-x86_64-darwin)
246246
ffi (1.17.0-x86_64-linux-gnu)
247-
fugit (1.9.0)
248-
et-orbi (~> 1, >= 1.2.7)
247+
fugit (1.11.1)
248+
et-orbi (~> 1, >= 1.2.11)
249249
raabro (~> 1.4)
250250
globalid (1.2.1)
251251
activesupport (>= 6.1)
@@ -549,6 +549,13 @@ GEM
549549
activejob (>= 7.2)
550550
activerecord (>= 7.2)
551551
railties (>= 7.2)
552+
solid_queue (0.8.1)
553+
activejob (>= 7.1)
554+
activerecord (>= 7.1)
555+
concurrent-ruby (>= 1.3.1)
556+
fugit (~> 1.11.0)
557+
railties (>= 7.1)
558+
thor (~> 1.3.1)
552559
sorted_set (1.0.3)
553560
rbtree
554561
set (~> 1.0)
@@ -585,7 +592,7 @@ GEM
585592
railties (>= 6.0.0)
586593
terser (1.1.20)
587594
execjs (>= 0.3.0, < 3)
588-
thor (1.3.0)
595+
thor (1.3.2)
589596
thruster (0.1.7)
590597
thruster (0.1.7-x86_64-darwin)
591598
thruster (0.1.7-x86_64-linux)
@@ -696,6 +703,7 @@ DEPENDENCIES
696703
sidekiq
697704
sneakers
698705
solid_cache
706+
solid_queue
699707
sprockets-rails (>= 2.0.0)
700708
sqlite3 (>= 2.0)
701709
stackprof

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Use [Solid Queue](https://github.com/rails/solid_queue) as the default Active Job backend in production, configured as a separate cache database in config/database.yml. In a single-server deployment, it'll run as a Puma plugin. This is configured in `config/deploy.yml` and can easily be changed to use a dedicated jobs machine.
2+
3+
*DHH*
4+
15
* Use [Solid Cache](https://github.com/rails/solid_cache) as the default Rails.cache backend in production, configured as a separate cache database in config/database.yml.
26

37
*DHH*

railties/lib/rails/generators/app_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def run_kamal
756756
def run_solid
757757
return if skip_solid? || !bundle_install?
758758

759-
rails_command "solid_cache:install"
759+
rails_command "solid_cache:install solid_queue:install"
760760
end
761761

762762
def add_bundler_platforms

railties/lib/rails/generators/rails/app/templates/Gemfile.tt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ gem "tzinfo-data", platforms: %i[ <%= bundler_windows_platforms %> jruby ]
1818

1919
# Use the database-backed Solid Cache adapter for Rails.cache [https://github.com/rails/solid_cache]
2020
gem "solid_cache"
21+
22+
# Use the database-backed Solid Queue adapter for Active Job [https://github.com/rails/solid_queue]
23+
gem "solid_queue"
2124
<% end -%>
2225
<% if depend_on_bootsnap? -%>
2326

railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ production:
6969
<<: *primary_production
7070
database: <%= app_name %>_production_cache
7171
migrations_paths: db/cache_migrate
72+
queue:
73+
<<: *primary_production
74+
database: <%= app_name %>_production_queue
75+
migrations_paths: db/queue_migrate
7276
<%- end -%>

railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,8 @@ production:
101101
<<: *primary_production
102102
database: <%= app_name %>_production_cache
103103
migrations_paths: db/cache_migrate
104+
queue:
105+
<<: *primary_production
106+
database: <%= app_name %>_production_queue
107+
migrations_paths: db/queue_migrate
104108
<%- end -%>

railties/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,9 @@ production:
5858
<<: *default
5959
database: storage/production_cache.sqlite3
6060
migrations_paths: db/cache_migrate
61+
queue:
62+
<<: *default
63+
database: storage/production_queue.sqlite3
64+
migrations_paths: db/queue_migrate
6165
<%- end -%>
6266
<%- end -%>

railties/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ production:
6969
<<: *primary_production
7070
database: <%= app_name %>_production_cache
7171
migrations_paths: db/cache_migrate
72+
queue:
73+
<<: *primary_production
74+
database: <%= app_name %>_production_queue
75+
migrations_paths: db/queue_migrate
7276
<%- end -%>

railties/lib/rails/generators/rails/app/templates/config/deploy.yml.tt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ servers:
1111
# job:
1212
# hosts:
1313
# - 192.168.0.1
14-
# cmd: bin/solid_queue work
14+
# cmd: bin/jobs
1515

1616
# Credentials for your image host.
1717
registry:
@@ -28,12 +28,28 @@ registry:
2828
env:
2929
secret:
3030
- RAILS_MASTER_KEY
31+
<% if skip_solid? -%>
3132
# clear:
3233
# # Set number of cores available to the application on each server (default: 1).
3334
# WEB_CONCURRENCY: 2
3435

35-
# # Match this to the database server to configure Active Record correctly
36+
# # Match this to any external database server to configure Active Record correctly
3637
# DB_HOST: 192.168.0.2
38+
<% else -%>
39+
clear:
40+
# Run the Solid Queue Supervisor inside the web server's Puma process to do jobs.
41+
# When you start using multiple servers, you should split out job processing to a dedicated machine.
42+
SOLID_QUEUE_IN_PUMA: true
43+
44+
# Set number of processes dedicated to Solid Queue (default: 1)
45+
# JOB_CONCURRENCY: 3
46+
47+
# Set number of cores available to the application on each server (default: 1).
48+
# WEB_CONCURRENCY: 2
49+
50+
# Match this to any external database server to configure Active Record correctly
51+
# DB_HOST: 192.168.0.2
52+
<% end -%>
3753

3854
<% unless skip_storage? %>
3955
# Use a persistent storage volume for sqlite database files and local Active Storage files.

0 commit comments

Comments
 (0)