Skip to content

Commit

Permalink
Merge pull request seuros#70 from mrsimo/options-per-process
Browse files Browse the repository at this point in the history
Options per process
  • Loading branch information
seuros committed Mar 11, 2015
2 parents 6d16ad6 + 9b152da commit c19b9d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Configurable options, shown here with defaults:
:sidekiq_timeout => 10
:sidekiq_role => :app
:sidekiq_processes => 1
:sidekiq_options_per_process => nil
:sidekiq_concurrency => nil
:sidekiq_monit_templates_path => 'config/deploy/templates'
:sidekiq_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiq" # Only for capistrano2.5
Expand All @@ -55,6 +56,19 @@ There is a known bug that prevents sidekiq from starting when pty is true
set :pty, false
```

## Multiple processes

You can configure sidekiq to start with multiple processes. Just set the proper amount in `sidekiq_processes`.

You can also customize the configuration for every process. If you want to do that, just set
`sidekiq_options_per_process` with an array of the configuration options that you want in string format.
This example should boot the first process with the queue `high` and the second one with the queues `default`
and `low`:

```ruby
set :sidekiq_options_per_process, ["--queue high", "--queue default --queue low"]
```

## Customizing the monit sidekiq templates

If you need change some config in redactor, you can
Expand Down
6 changes: 6 additions & 0 deletions lib/capistrano/tasks/capistrano2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
_cset(:sidekiq_timeout) { 10 }
_cset(:sidekiq_role) { :app }
_cset(:sidekiq_processes) { 1 }
_cset(:sidekiq_options_per_process) { nil }

if fetch(:sidekiq_default_hooks)
before 'deploy:update_code', 'sidekiq:quiet'
Expand Down Expand Up @@ -56,6 +57,11 @@ def start_process(pid_file, idx)
fetch(:sidekiq_queue).each do |queue|
args.push "--queue #{queue}"
end if fetch(:sidekiq_queue)

if process_options = fetch(:sidekiq_options_per_process)
args.push process_options[idx]
end

args.push fetch(:sidekiq_options)

if defined?(JRUBY_VERSION)
Expand Down
4 changes: 4 additions & 0 deletions lib/capistrano/tasks/sidekiq.cap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace :load do
set :sidekiq_timeout, -> { 10 }
set :sidekiq_role, -> { :app }
set :sidekiq_processes, -> { 1 }
set :sidekiq_options_per_process, -> { nil }
# Rbenv and RVM integration
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
Expand Down Expand Up @@ -94,6 +95,9 @@ namespace :sidekiq do
end
args.push "--config #{fetch(:sidekiq_config)}" if fetch(:sidekiq_config)
args.push "--concurrency #{fetch(:sidekiq_concurrency)}" if fetch(:sidekiq_concurrency)
if process_options = fetch(:sidekiq_options_per_process)
args.push process_options[idx]
end
# use sidekiq_options for special options
args.push fetch(:sidekiq_options) if fetch(:sidekiq_options)

Expand Down

0 comments on commit c19b9d8

Please sign in to comment.