Worker Queue
🛤️

Worker Queue

Created
Apr 8, 2022 8:13 AM
Department
Engineering
Category
Deployment
Technology
Ruby on Rails
Tags
Date
URL

Setting up a sidekiq - Redis worker server in Rails and Cloud66

Project configuration

  1. Add gem 'sidekiq' to your project’s Gemfile
  2. Create a Procfile at your project’s root directory with the following contents
  3. worker: bundle exec sidekiq -e $RAILS_ENV
  4. Add the following line to config/environments/production.rb. Do the same for staging
  5. config.active_job.queue_adapter = :sidekiq
  6. For Rails 6+: Create a new config/sidekiq.yml file with the following contents
  7. :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

  1. In the Cloud66 main app screen, click on the large + sign beside Add-Ins, and select Redis
  2. 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.

  1. Click on Process Server
  2. 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