Sha256: eee0f62a9e28a463eea99ecd64ae300d2189d781dd5198b070c9b8362c608fa1

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

# Monit configuration for PM2 :  <%= fetch(:application) %>  (<%= fetch(:stage) %>)
<%  fetch(:monit_pm2_app_instances, 1).times do |n| %>
  check process <%= fetch(:application) %>_<%= fetch(:stage) %>_pm2_<%= n %> with pidfile <%= fetch(:monit_pm2_pid_path) %>/<%= fetch(:monit_pm2_app_name) %>-<%= n %>.pid
    group pm2-<%= fetch(:application) %>-<%= fetch(:stage) %>
    start program = "<%= monit_pm2_prefixed("pm2 restart #{fetch(:monit_pm2_start_script)} --env #{fetch(:monit_pm2_stage)}") %>"
    stop program = "<%= monit_pm2_prefixed("pm2 stop #{fetch(:monit_pm2_start_script)} --env #{fetch(:monit_pm2_stage)}") %>"
    # if does not exist then start # (default)
    if does not exist for 3 cycles then <%= monit_alert %>
    # if 3 restarts within 10 cycles then <%= monit_alert %>
    # if cpu > 50% then <%= monit_alert %>
    # if cpu > 50% for 3 cycles then restart
    # if 5 restarts within 15 cycles then timeout
    # alert <%= fetch(:monit_mail_to) %> only on { pid }
    if changed pid 3 times within 10 cycles then <%= monit_alert %>
<% end %>


<% if fetch(:monit_pm2_check_website, false) %>
# Check website for pm2: <%= fetch(:application) %> [<%= fetch(:stage) %>]
check host "<%= fetch(:monit_pm2_website_name).gsub(/\s+/,'-').gsub(/_/,'-').gsub(/:/,'-').gsub(/--+/,'-') %>" with address <%= fetch(:monit_pm2_website_url) %>
  <% if fetch(:monit_pm2_website_ssl) %>if failed port 443 protocol https and certificate valid > 2 days then <%= monit_alert %><% end %>
  if failed 
  <% if fetch(:monit_pm2_website_ssl) %>
    port 443
    type TCPSSL
    protocol https
  <% else %>
    port 80
    protocol http
  <% end %>
    status = 200
    with timeout 13 seconds for 5 cycles 
  then <%= monit_alert %>

<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magic_recipes_two-0.0.95 lib/generators/capistrano/magic_recipes/templates/monit/pm2.erb