Skip to content

Commit ba417f1

Browse files
committed
Add explicit development instructions to the README.
1 parent 51c75be commit ba417f1

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ production:
4343
migrations_paths: db/queue_migrate
4444
```
4545
46-
Note: Calling `bin/rails solid_queue:install` will automatically add `config.solid_queue.connects_to = { database: { writing: :queue } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `queue` name in `database.yml` for this to match!). But if you want to use Solid Queue in a different environment (like staging or even development), you'll have to manually add that `config.solid_queue.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_queue.connects_to`.
47-
4846
Then run `db:prepare` in production to ensure the database is created and the schema is loaded.
4947

5048
Now you're ready to start processing jobs by running `bin/jobs` on the server that's doing the work. This will start processing jobs in all queues using the default configuration. See [below](#configuration) to learn more about configuring Solid Queue.
@@ -53,6 +51,39 @@ For small projects, you can run Solid Queue on the same machine as your webserve
5351

5452
**Note**: future changes to the schema will come in the form of regular migrations.
5553

54+
### Usage in development and other non-production environments
55+
56+
Calling `bin/rails solid_queue:install` will automatically add `config.solid_queue.connects_to = { database: { writing: :queue } }` to `config/environments/production.rb`. In order to use Solid Queue in other environments (such as development or staging), you'll need to add a similar configuration(s).
57+
58+
For example, if you're using Sqlite in development, update `database.yml` as follows:
59+
60+
```yaml
61+
development:
62+
primary:
63+
<<: *default
64+
database: storage/development.sqlite3
65+
queue:
66+
<<: *default
67+
database: storage/development_queue.sqlite3
68+
migrations_paths: db/queue_migrate
69+
```
70+
71+
Next, add the following to `development.rb`
72+
73+
```ruby
74+
# Use Solid Queue in Development.
75+
config.active_job.queue_adapter = :solid_queue
76+
config.solid_queue.connects_to = {database: {writing: :queue}}
77+
```
78+
79+
Once you've added this, again run `db:prepare` to create the Solid Queue database and load the schema.
80+
81+
Finally, in order for jobs to be processed, you'll need to have Solid Queue running. In Development, this can be done via the Puma plugin. In `puma.rb` update the following line:
82+
83+
```ruby
84+
# You can either set the env var, or check for development
85+
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] || Rails.env.development?
86+
```
5687

5788
### Single database configuration
5889

@@ -86,6 +117,7 @@ Solid Queue was designed for the highest throughput when used with MySQL 8+ or P
86117
### Workers, dispatchers and scheduler
87118

88119
We have several types of actors in Solid Queue:
120+
89121
- _Workers_ are in charge of picking jobs ready to run from queues and processing them. They work off the `solid_queue_ready_executions` table.
90122
- _Dispatchers_ are in charge of selecting jobs scheduled to run in the future that are due and _dispatching_ them, which is simply moving them from the `solid_queue_scheduled_executions` table over to the `solid_queue_ready_executions` table so that workers can pick them up. On top of that, they do some maintenance work related to [concurrency controls](#concurrency-controls).
91123
- The _scheduler_ manages [recurring tasks](#recurring-tasks), enqueuing jobs for them when they're due.
@@ -99,7 +131,6 @@ By default, Solid Queue will try to find your configuration under `config/queue.
99131
bin/jobs -c config/calendar.yml
100132
```
101133

102-
103134
This is what this configuration looks like:
104135

105136
```yml

0 commit comments

Comments
 (0)