mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Add process index support to cap recipe
This commit is contained in:
parent
db48ff74bf
commit
5804ad67d3
1 changed files with 6 additions and 6 deletions
|
@ -13,21 +13,21 @@ Capistrano::Configuration.instance.load do
|
|||
|
||||
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}"
|
||||
fetch(:sidekiq_processes).times do |idx|
|
||||
yield((process == 0 ? "#{fetch(:sidekiq_pid)}" : "#{fetch(:sidekiq_pid)}-#{process}"), idx)
|
||||
end
|
||||
end
|
||||
|
||||
desc "Quiet sidekiq (stop accepting new work)"
|
||||
task :quiet, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||
for_each_process do |pid_file|
|
||||
for_each_process do |pid_file, idx|
|
||||
run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && #{fetch(:sidekiqctl_cmd)} quiet #{pid_file} ; fi"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Stop sidekiq"
|
||||
task :stop, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||
for_each_process do |pid_file|
|
||||
for_each_process do |pid_file, idx|
|
||||
run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && #{fetch(:sidekiqctl_cmd)} stop #{pid_file} #{fetch :sidekiq_timeout} ; fi"
|
||||
end
|
||||
end
|
||||
|
@ -35,8 +35,8 @@ Capistrano::Configuration.instance.load do
|
|||
desc "Start sidekiq"
|
||||
task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||
rails_env = fetch(:rails_env, "production")
|
||||
for_each_process do |pid_file|
|
||||
run "cd #{current_path} ; nohup #{fetch(:sidekiq_cmd)} -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{pid_file} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
|
||||
for_each_process do |pid_file, idx|
|
||||
run "cd #{current_path} ; nohup #{fetch(:sidekiq_cmd)} -e #{rails_env} -C #{current_path}/config/sidekiq.yml -i #{idx} -P #{pid_file} >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue