Skip to content

Commit

Permalink
Try execute on the monit.conf mv command in case the deploy user does…
Browse files Browse the repository at this point in the history
…n't have sudo
  • Loading branch information
Ben Crouse committed Feb 27, 2015
1 parent 58c7bc3 commit f9bb075
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/capistrano/tasks/monit.cap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ namespace :sidekiq do
on roles(fetch(:sidekiq_role)) do |role|
@role = role
template_sidekiq 'sidekiq_monit', "#{fetch(:tmp_dir)}/monit.conf", @role
sudo "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{sidekiq_service_name}.conf"

mv_command = "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{sidekiq_service_name}.conf"

# Try execute in case the deploy user doesn't have sudo to mv
begin
execute mv_command
rescue
sudo mv_command
end

sudo "#{fetch(:monit_bin)} reload"
end
end
Expand Down

0 comments on commit f9bb075

Please sign in to comment.