Skip to content

Commit

Permalink
try to configure before failing hard.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zane Shannon committed Feb 12, 2015
1 parent 2620836 commit 5f4c898
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/capistrano/tasks/monit.cap
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ namespace :sidekiq do
@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"
sudo "#{fetch(:monit_bin)} reload"
end
end

desc 'Monitor Sidekiq monit-service'
task :monitor do
on roles(fetch(:sidekiq_role)) do
fetch(:sidekiq_processes).times do |idx|
sudo "#{fetch(:monit_bin)} monitor #{sidekiq_service_name(idx)}"
begin
sudo "#{fetch(:monit_bin)} monitor #{sidekiq_service_name(idx)}"
rescue
invoke 'sidekiq:monit:config'
sudo "#{fetch(:monit_bin)} monitor #{sidekiq_service_name(idx)}"
end
end
end
end
Expand All @@ -44,7 +50,11 @@ namespace :sidekiq do
task :unmonitor do
on roles(fetch(:sidekiq_role)) do
fetch(:sidekiq_processes).times do |idx|
sudo "#{fetch(:monit_bin)} unmonitor #{sidekiq_service_name(idx)}"
begin
sudo "#{fetch(:monit_bin)} unmonitor #{sidekiq_service_name(idx)}"
rescue
# no worries here
end
end
end
end
Expand Down

0 comments on commit 5f4c898

Please sign in to comment.