Sha256: dd6f9d47f677d78871fda434c2fdf7d295b8bd2014796640f05ef2c9a1e9df7c

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

namespace :load do
  task :defaults do
    set :sidekiq_monit_conf_dir, -> { '/etc/monit/conf.d' }
    set :monit_bin, -> { '/usr/bin/monit' }
  end
end


namespace :sidekiq do
  namespace :monit do
    desc 'Config Sidekiq monit-service'
    task :config do
      on roles(fetch(:sidekiq_role)) do |role|
        @role = role
        template_sidekiq 'sidekiq_monit.conf', "#{fetch(:tmp_dir)}/monit.conf", @role
        sudo "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{sidekiq_service_name}.conf"
      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)}"
        end
      end
    end

    desc 'Unmonitor Sidekiq monit-service'
    task :unmonitor do
      on roles(fetch(:sidekiq_role)) do
        fetch(:sidekiq_processes).times do |idx|
          sudo "#{fetch(:monit_bin)} unmonitor #{sidekiq_service_name(idx)}"
        end
      end
    end

    desc 'Disable Sidekiq monit-service'
    task :start do
      on roles(fetch(:sidekiq_role)) do
        fetch(:sidekiq_processes).times do |idx|
          sudo "#{fetch(:monit_bin)} start #{sidekiq_service_name(idx)}"
        end
      end
    end

    desc 'Disable Sidekiq monit-service'
    task :stop do
      on roles(fetch(:sidekiq_role)) do
        fetch(:sidekiq_processes).times do |idx|
          sudo "#{fetch(:monit_bin)} stop #{sidekiq_service_name(idx)}"
        end
      end
    end

    desc 'Disable Sidekiq monit-service'
    task :restart do
      on roles(fetch(:sidekiq_role)) do
        fetch(:sidekiq_processes).times do |idx|
          sudo "#{fetch(:monit_bin)} restart #{sidekiq_service_name(idx)}"
        end
      end
    end

    def sidekiq_service_name(index=nil)
      fetch(:sidekiq_service_name, "sidekiq_#{fetch(:application)}") + index.to_s
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
capistrano-sidekiq-0.3.7 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.6 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.5 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.4 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.3 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.2 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.1 lib/capistrano/tasks/monit.cap
capistrano-sidekiq-0.3.0 lib/capistrano/tasks/monit.cap