Setting up a sidekiq - redis worker server in Rails and Cloud66
Project configuration
- Add
gem 'sidekiq'
to your project’sGemfile
- Create a
Procfile
at your project’s root directory with the following contentsworker: bundle exec sidekiq -e $RAILS_ENV
- Add the following line to
config/environments/production.rb
. Do the same forstaging
config.active_job.queue_adapter = :sidekiq
- For Rails 6+: Create a new
config/sidekiq.yml
file with the following contents:queues: - default - active_storage_analysis - active_storage_purge
This will ensure jobs launched by ActiveStorage won’t sit idle forever. If you are using any queue other than
default
in any of your jobs. make sure to add it here as well
- optional: To track sidekiq’s performance, add the following to the
config/routes.rb
file:require 'sidekiq/web' mount Sidekiq::Web => '/sidekiq'
Cloud66 configuration
Redis
- In the Cloud66 main app screen, click on the large + sign besides Add-Ins, and select Redis
- Depending on your environment
- Staging: Select Existing Server and click on Add
- Production: Select New Cloud Server and choose one according to your needs. Ask your team leader for guidance if required.
Process server
Once you have pushed and redeployed, a new Process Server will appear on the Cloud66 stack.
- Click on Process Server
- Depending on your environment
- Staging: Click on the green + button (Scale up this process group)
- Production: Select New Process Server and choose one according to your needs. Ask your team leader for guidance if required. Then do the same as staging