Sha256: fe25d67efdf877dd6bf14f0de0059f75000c66354b035cd8406c51c44ca985cb

Contents?: true

Size: 928 Bytes

Versions: 8

Compression:

Stored size: 928 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
    unicorn
    syntax
    restart
  end
  after "deploy:setup", "monit:setup"
  
  task(:nginx, roles: :web) { monit_config "nginx" }
  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

8 entries across 8 versions & 1 rubygems

Version Path
redde-0.1.1 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.1.0 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.0.8 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.0.7 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.0.6 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.0.5 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.0.4 lib/generators/redde/deploy/templates/recipes/monit.rb
redde-0.0.3 lib/generators/redde/deploy/templates/recipes/monit.rb