Permalink
Browse files

You can now use signals to quiet/stop sidekiq, much faster.

  • Loading branch information...
penso committed Apr 24, 2014
1 parent 559bc63 commit 03d3ba127508064cbeb596c54ffc8f6af7029aa9
Showing with 13 additions and 7 deletions.
  1. +13 −7 lib/capistrano/tasks/sidekiq.cap
@@ -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
@@ -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(' ')

0 comments on commit 03d3ba1

Please sign in to comment.