mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
adding sidekiq_processes option for running multiple sidekiq processes per host
This commit is contained in:
parent
c03d857362
commit
b9b842fa58
1 changed files with 18 additions and 6 deletions
|
@ -4,26 +4,38 @@ Capistrano::Configuration.instance.load do
|
|||
after "deploy:start", "sidekiq:start"
|
||||
after "deploy:restart", "sidekiq:restart"
|
||||
|
||||
_cset(:sidekiq_timeout) { 10 }
|
||||
_cset(:sidekiq_role) { :app }
|
||||
_cset(:sidekiq_pid) { "#{current_path}/tmp/pids/sidekiq.pid" }
|
||||
_cset(:sidekiq_timeout) { 10 }
|
||||
_cset(:sidekiq_role) { :app }
|
||||
_cset(:sidekiq_pid) { "#{current_path}/tmp/pids/sidekiq.pid" }
|
||||
_cset(:sidekiq_processes) { 1 }
|
||||
|
||||
namespace :sidekiq do
|
||||
def for_each_process(&block)
|
||||
0.upto(fetch(:sidekiq_processes) - 1) do |process|
|
||||
yield process == 0 ? "#{fetch(:sidekiq_pid)}" : "#{fetch(:sidekiq_pid)}-#{process}"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Quiet sidekiq (stop accepting new work)"
|
||||
task :quiet, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||
run "if [ -d #{current_path} ] && [ -f #{fetch :sidekiq_pid} ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{fetch :sidekiq_pid} ; fi"
|
||||
for_each_process do |pid_file|
|
||||
run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{pid_file} ; fi"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Stop sidekiq"
|
||||
task :stop, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||
run "if [ -d #{current_path} ] && [ -f #{fetch :sidekiq_pid} ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{fetch :sidekiq_pid} #{fetch :sidekiq_timeout} ; fi"
|
||||
for_each_process do |pid_file|
|
||||
run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{pid_file} #{fetch :sidekiq_timeout} ; fi"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Start sidekiq"
|
||||
task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||
rails_env = fetch(:rails_env, "production")
|
||||
run "cd #{current_path} ; nohup #{fetch(:bundle_cmd, "bundle")} exec sidekiq -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{fetch :sidekiq_pid} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
|
||||
for_each_process do |pid_file|
|
||||
run "cd #{current_path} ; nohup #{fetch(:bundle_cmd, "bundle")} exec sidekiq -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{pid_file} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
|
||||
end
|
||||
end
|
||||
|
||||
desc "Restart sidekiq"
|
||||
|
|
Loading…
Add table
Reference in a new issue