Skip to content

Commit

Permalink
Update readme to talk about Action Cable if using in development with…
Browse files Browse the repository at this point in the history
… a database.
  • Loading branch information
evdevdev committed Dec 19, 2024
1 parent 520dfea commit 8e69554
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ For small projects, you can run Solid Queue on the same machine as your webserve

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).

For example, if you're using Sqlite in development, update `database.yml` as follows:
For example, if you're using SQLite in development, update `database.yml` as follows:

```yaml
```diff
development:
primary:
<<: *default
database: storage/development.sqlite3
queue:
<<: *default
database: storage/development_queue.sqlite3
migrations_paths: db/queue_migrate
+ queue:
+ <<: *default
+ database: storage/development_queue.sqlite3
+ migrations_paths: db/queue_migrate
```

Next, add the following to `development.rb`
Expand All @@ -101,7 +101,7 @@ Next, add the following to `development.rb`
config.solid_queue.connects_to = {database: {writing: :queue}}
```

Once you've added this, again run `db:prepare` to create the Solid Queue database and load the schema.
Once you've added this, run `db:prepare` to create the Solid Queue database and load the schema.

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:

Expand All @@ -110,6 +110,34 @@ Finally, in order for jobs to be processed, you'll need to have Solid Queue runn
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] || Rails.env.development?
```

**Import Note about Action Cable**: If you use Action Cable (or anything dependent on Action Cable, such as Turbo Streams), you will need to also need to update it to use a database.

In `config/cable.yml`

```diff
development:
- adapter: async
+ adapter: solid_cable
+ connects_to:
+ database:
+ writing: cable
+ polling_interval: 0.1.seconds
+ message_retention: 1.day
```

In `config/database.yml`

```diff
development:
primary:
<<: *default
database: storage/development.sqlite3
+ cable:
+ <<: *default
+ database: storage/development_cable.sqlite3
+ migrations_paths: db/cable_migrate
```

### Single database configuration

Running Solid Queue in a separate database is recommended, but it's also possible to use one single database for both the app and the queue. Just follow these steps:
Expand Down

0 comments on commit 8e69554

Please sign in to comment.