Posted 9 months ago. Visible to the public.

Using Sidekiq with Procfile and Capistrano (example)

Here is an example configuration for using Sidekiq with our Procfile support and Capistrano.

Sidekiq specific steps in lib/capistrano/tasks/sidekiq.rake. Please make sure the roles meet your needs:

Copy
# frozen_string_literal: true namespace :sidekiq do desc 'quiet all sidekiq processes so they stop accepting new jobs' task :quiet do on roles :cron do # The TSTP signal tells sidekiq to quiet all workers. # see: https://github.com/mperham/sidekiq/wiki/Signals#tstp invoke('opscomplete:supervisor:signal_procs', 'TSTP', 'sidekiq') end end desc 'print a backtrace for all sidekiq threads to the logfile' task :trace do on roles :cron do # The TTIN signal tells sidekiq to print a backtrace for all threads to the logfile. # see: https://github.com/mperham/sidekiq/wiki/Signals#ttin invoke('opscomplete:supervisor:signal_procs', 'TTIN', 'sidekiq') end end desc 'shuts down all sidekiq processes within the configured timout' task :term do on roles :cron do # The TERM signal tells sidekiq to kill quiet all processes for the configured timout time and then kill them. # see: https://github.com/mperham/sidekiq/wiki/Signals#term invoke('opscomplete:supervisor:signal_procs', 'TERM', 'sidekiq') end end end

Sidekiq/Supervisor specific hooks for config/deploy.rb:

Copy
# Update and Restart supervisor config after 'deploy:starting', 'sidekiq:quiet' after 'deploy:updating', 'opscomplete:supervisor:gen_config' after 'deploy:published', 'opscomplete:supervisor:restart_procs' # Terminate sidekiq quiet processes (new processes get started by supervisor) after 'deploy:failed', 'sidekiq:term'

You Procfile should include e.g. this command for running sidekiq:

Copy
sidekiq: bundle exec sidekiq --config config/sidekiq.yml

Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.

Owner of this card:

Avatar
Kim Jahn
Last edit:
9 months ago
by Kim Jahn
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Kim Jahn to opscomplete
This website uses short-lived cookies to improve usability.
Accept or learn more