Skip to content

Commit

Permalink
You can now use signals to quiet/stop sidekiq, much faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
penso committed Apr 24, 2014
1 parent 559bc63 commit 03d3ba1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/capistrano/tasks/sidekiq.cap
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,25 @@ namespace :sidekiq do
end

def stop_sidekiq(pid_file)
if fetch(:stop_sidekiq_in_background, fetch(:sidekiq_run_in_background))
if fetch(:sidekiq_use_signals)
background "kill -TERM `cat #{pid_file}`"
elsif fetch(:stop_sidekiq_in_background, fetch(:sidekiq_run_in_background))
background :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
else
execute :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
end
end

def quit_sidekiq(pid_file)
begin
execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
rescue SSHKit::Command::Failed
# If gems are not installed eq(first deploy) and sidekiq_default_hooks as active
warn 'sidekiqctl not found (ignore if this is the first deploy)'
if fetch(:sidekiq_use_signals)
background "kill -USR1 `cat #{pid_file}`"
else
begin
execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
rescue SSHKit::Command::Failed
# If gems are not installed eq(first deploy) and sidekiq_default_hooks as active
warn 'sidekiqctl not found (ignore if this is the first deploy)'
end
end
end

Expand All @@ -85,7 +91,7 @@ namespace :sidekiq do
args.push "--daemon"
end

if fetch(:start_sidekiq_in_background, fetch(:sidekiq_run_in_background))
if fetch(:start_sidekiq_in_background, fetch(:sidekiq_run_in_background))
background :bundle, :exec, :sidekiq, args.compact.join(' ')
else
execute :bundle, :exec, :sidekiq, args.compact.join(' ')
Expand Down

0 comments on commit 03d3ba1

Please sign in to comment.