Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 27, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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