docker/monitrc.erb
set daemon 120
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
basedir /var/lib/monit/events
slots 100
set alert ops@127.0.0.1
set mailserver 127.0.0.1 port 2525
set mail-format {
subject: $HOST *$ACTION* `$SERVICE $EVENT` $DESCRIPTION on $DATE
}
check process puma
with pidfile /run/puma.pid
start program = "/sbin/start-stop-daemon --pidfile /run/puma.pid --start --background --make-pidfile --exec /usr/local/bin/puma -- --config /app/docker/puma_config.rb"
stop program = "/sbin/start-stop-daemon --pidfile /run/puma.pid --stop --remove-pidfile"
check process varnish
with pidfile /run/varnishd.pid
start program = "/sbin/start-stop-daemon --pidfile /run/varnishd.pid --start --exec /app/docker/varnish"
stop program = "/sbin/start-stop-daemon --pidfile /run/varnishd.pid --stop"
check process memcache
with pidfile /run/memcached.pid
start program = "/etc/init.d/memcached start"
stop program = "/etc/init.d/memcached stop"
<% 0.upto((ENV['NUM_DELAYED_JOB_WORKERS'] || 1).to_i - 1) do |i| %>
check process delayed_job.<%= i %>
with pidfile /run/delayed_job.<%= i %>.pid
start program = "/sbin/start-stop-daemon --pidfile /run/delayed_job.<%= i %>.pid --start --background --make-pidfile --exec /usr/local/bin/rake -- --rakefile /app/Rakefile jobs:work"
stop program = "/sbin/start-stop-daemon --pidfile /run/delayed_job.<%= i %>.pid --stop --remove-pidfile"
if failed
port 6081
protocol http
request /instance_health
with timeout 2 seconds
then restart
<% end %>
check process metrics
with pidfile /run/metrics.pid
start program = "/sbin/start-stop-daemon --pidfile /run/metrics.pid --start --background --make-pidfile --exec /app/docker/metrics"
stop program = "/sbin/start-stop-daemon --pidfile /run/metrics.pid --stop --remove-pidfile"
check process mailslack
with pidfile /run/mailslack.pid
start program = "/sbin/start-stop-daemon --pidfile /run/mailslack.pid --start --background --make-pidfile --exec /usr/bin/tcpserver 127.0.0.1 2525 /app/docker/mailslack.rb"
stop program = "/sbin/start-stop-daemon --pidfile /run/mailslack.pid --stop --remove-pidfile"
check filesystem rootfs
with path /
if space usage > 80% then exec /app/bin/free_storage
check system $HOST
if memory usage > 90% for 2 cycles then alert
if loadavg (1min) > <%= ENV['NPROC'] %> for 2 cycles then alert