Skip to content

Commit

Permalink
Merge pull request seuros#104 from hbin/development
Browse files Browse the repository at this point in the history
Use SSHKit command_map
  • Loading branch information
seuros committed Sep 14, 2015
2 parents 8d8d931 + 8a49d76 commit 0d85831
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ set :sidekiq_monit_use_sudo, false
- [Alex Yakubenko] (https://github.com/alexyakubenko)
- [Robert Strobl] (https://github.com/rstrobl)
- [Eurico Doirado] (https://github.com/okoriko)
- [Huang Bin](https://github.com/hbin)

## Contributing

Expand Down
12 changes: 7 additions & 5 deletions lib/capistrano/tasks/sidekiq.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace :load do
# Rbenv and RVM integration
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
# Bundler integration
set :bundle_bins, fetch(:bundle_bins).to_a.concat(%w(sidekiq sidekiqctl))
end
end

Expand Down Expand Up @@ -64,10 +66,10 @@ namespace :sidekiq do
if fetch(:sidekiq_use_signals)
background "kill -TERM `cat #{pid_file}`"
else
background :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
background :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
end
else
execute :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
execute :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
end
end

Expand All @@ -76,7 +78,7 @@ namespace :sidekiq do
background "kill -USR1 `cat #{pid_file}`"
else
begin
execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
execute :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)'
Expand Down Expand Up @@ -111,9 +113,9 @@ namespace :sidekiq do
end

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<% processes_pids.each_with_index do |pid_file, idx| %>
check process <%= sidekiq_service_name(idx) %>
with pidfile "<%= pid_file %>"
start program = "/bin/su - <%= @role.user %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec sidekiq <%= sidekiq_config %> --index <%= idx %> --pidfile <%= pid_file %> --environment <%= fetch(:sidekiq_env) %> <%= sidekiq_concurrency %> <%= sidekiq_logfile %> <%= sidekiq_queues %> -d'" with timeout 30 seconds
start program = "/bin/su - <%= @role.user %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:sidekiq] %> <%= sidekiq_config %> --index <%= idx %> --pidfile <%= pid_file %> --environment <%= fetch(:sidekiq_env) %> <%= sidekiq_concurrency %> <%= sidekiq_logfile %> <%= sidekiq_queues %> -d'" with timeout 30 seconds

stop program = "/bin/su - <%= @role.user %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec sidekiqctl stop <%= pid_file %>'" with timeout <%= fetch(:sidekiq_timeout).to_i + 10 %> seconds
stop program = "/bin/su - <%= @role.user %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:sidekiqctl] %> stop <%= pid_file %>'" with timeout <%= fetch(:sidekiq_timeout).to_i + 10 %> seconds
group <%= fetch(:sidekiq_monit_group, fetch(:application)) %>-sidekiq

<% end %>

0 comments on commit 0d85831

Please sign in to comment.