Run Sidekiq in a Local Environment
By default, Workarea applications are configured to run Sidekiq inline for local development. In some cases, however, it could be desirable to have an application run with Sidekiq processing jobs in the background to better match a live, production environment.
To achieve this, there are number of steps that need to be taken to allow the development environment to function in this way. The first is modifying the environment configuration that is added for development by the Workarea app template. In
config/environments/development.rb, you will see the line below
# Run Sidekiq tasks synchronously so that Sidekiq is not required in Development require 'sidekiq/testing/inline'
Remove this line or comment it out. This stops the application from running Sidekiq jobs inline during the execution of a web request. Without this line, the application will add jobs to redis for the Sidekiq process to find and process. To run sidekiq, you will need to open a terminal, navigate to your application's directory, and start the sidekiq process, exactly as you would start a web server for the application itself.
$ cd path/to/your/app $ bundle exec sidekiq
When the command executes you will see a message that sidekiq has started. This window must remain open and running for sidekiq to continue to function. If you prefer, you can run sidekiq as a daemon with the
--daemon flag when starting the process.
Run Sidekiq in a Docker Environment
When using Docker for Workarea development, the generated
docker-compose.yml file provides a commented out service you can use to run Sidekiq in a separate container. Just uncomment the following lines and run
# sidekiq: # <<: *web # command: ['sh', './docker-wait.sh', 'sidekiq'] # depends_on: # - web # ports: 
Note: Docker environments still require you to remove the
require shown above from your
How'd We Do?
Was this article missing something?
Was it not quite what you were looking for?
Do you have suggestions on how we could improve this article or your experience in general?
If so, please take a moment to let us know!
Your invaluable feedback will help everyone better understand the platform!