Sha256: 35bfee8187d1dd72f024e3ffc09ebc98e7c0e7fcba2651d70f64b4e458483757

Contents?: true

Size: 1005 Bytes

Versions: 4

Compression:

Stored size: 1005 Bytes

Contents

namespace :monit do
  desc 'Install Monit'
  task :install do
    run "#{sudo} apt-get -y install monit"
  end
  after 'deploy:install', 'monit:install'

  desc 'Setup all Monit configuration'
  task :setup do
    monit_config 'monitrc', '/etc/monit/monitrc'
    nginx
    postgresql
    unicorn
    syntax
    reload
  end
  after 'deploy:setup', 'monit:setup'
  
  task(:nginx, roles: :web) { monit_config "nginx" }
  #task(:postgresql, roles: :db) { monit_config "postgresql" }
  task(:unicorn, roles: :app) { monit_config "unicorn" }

  %w[start stop restart syntax reload].each do |command|
    desc "Run Monit #{command} script"
    task command do
      run "#{sudo} service monit #{command}"
    end
  end
end

def monit_config(name, destination = nil)
  destination ||= "/etc/monit/conf.d/#{name}.conf"
  template "monit/#{name}.erb", "/tmp/monit_#{name}"
  run "#{sudo} mv /tmp/monit_#{name} #{destination}"
  run "#{sudo} chown root #{destination}"
  run "#{sudo} chmod 600 #{destination}"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
recipes_matic-1.1.0 lib/generators/recipes_matic/templates/config/deploy/recipes/monit.rb
recipes_matic-1.0.0 lib/generators/recipes_matic/templates/config/deploy/recipes/monit.rb
recipes_matic-0.2.0 lib/generators/recipes_matic/templates/config/deploy/recipes/monit.rb
recipes_matic-0.1.0 lib/generators/recipes_matic/templates/config/deploy/recipes/monit.rb