Sha256: 9e2077a30e146c3c317fbb61ae5d81247906fb1484594b4b9aea82829da86c5f

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

namespace :load do
  task :defaults do
    set :puma_monit_conf_dir, -> { "/etc/monit/conf.d/#{puma_monit_service_name}.conf" }
    set :puma_monit_bin, -> { "/usr/bin/monit" }
  end
end


namespace :puma do
  namespace :monit do
    desc 'Config Puma monit-service'
    task :config do
      on roles(fetch(:puma_role)) do |role|
        @role = role
        template_puma 'puma_monit.conf', "#{fetch(:tmp_dir)}/monit.conf", @role
        sudo "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:puma_monit_conf_dir)}"
      end
    end

    desc 'Monitor Puma monit-service'
    task :monitor do
      on roles(fetch(:puma_role)) do
        sudo "#{fetch(:puma_monit_bin)} monitor #{puma_monit_service_name}"
      end
    end

    desc 'Unmonitor Puma monit-service'
    task :unmonitor do
      on roles(fetch(:puma_role)) do
        sudo "#{fetch(:puma_monit_bin)}  unmonitor #{puma_monit_service_name}"
      end
    end

    desc 'Start Puma monit-service'
    task :start do
      on roles(fetch(:puma_role)) do
        sudo "#{fetch(:puma_monit_bin)}  start #{puma_monit_service_name}"
      end
    end

    desc 'Stop Puma monit-service'
    task :stop do
      on roles(fetch(:puma_role)) do
        sudo "#{fetch(:puma_monit_bin)}  stop #{puma_monit_service_name}"
      end
    end

    desc 'Restart Puma monit-service'
    task :restart do
      on roles(fetch(:puma_role)) do
        sudo "#{fetch(:puma_monit_bin)}  restart #{puma_monit_service_name}"
      end
    end

    def puma_monit_service_name
      fetch(:puma_monit_service_name, "puma_#{fetch(:application)}_#{fetch(:stage)}")
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
capistrano3-puma-1.0.0 lib/capistrano/tasks/monit.cap
capistrano3-puma-0.9.0 lib/capistrano/tasks/monit.cap
capistrano3-puma-0.8.5 lib/capistrano/tasks/monit.cap
capistrano3-puma-0.8.4 lib/capistrano/tasks/monit.cap