Scott Watermasysk
Solid Queue in Development
In Rails 8, SolidQueue is included by default. However, in development, you default to using the Async/in-memory job processor. This is OK for simple tasks, but I prefer running it in a separate process.
In a world over Overmind (and Foreman), this adds very little extra work to your development experience. In addition, knowing I have seen it all work together makes me much more confident about going to production.
I stumbled twice on this, so I figured I would document it for others (and likely my Google search in the future).
Here are the changes you need to make:
First, modify your database.yml file to specify the database you want to use. You could technically put this in your development database, but the cost of another database (especially SQLite) is zero locally, so I don't see why you would bother.
The core changes here:
- We specify the first database is now primary.
- We list the queue database
- We list the migration path for the queue database
development:
primary:
<<: *default
database: storage/development.sqlite3
queue:
<<: *default
database: storage/development_queue.sqlite3
migrations_paths: db/queue_migrate
Next, you need to go into your development.rb environment file and specify we want to use the SolidQueue and the database it should connect to.
config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = {database: {writing: :queue}}
Finally, to make it easy always to start the worker process, add this to your Procfile.dev
worker: bundle exec rake solid_queue:start
Now, when you run bin/dev
your jobs will run in their own process.