SET DAEMON 5
SET LOGFILE /var/log/monit.log
SET STATEFILE /var/lib/monit/state
#SET HTTPD UNIXSOCKET /var/run/monit.sock
#    allow user:pass
SET HTTPD PORT 2812 AND
    USE ADDRESS localhost
    ALLOW localhost
    ALLOW admin:monit
SET MAILSERVER
    box.handmadedev.org
    PORT 587
    USERNAME "noreply@handmadedev.org"
    PASSWORD "<EMAIL PASSWORD>"
    USING tlsv1
SET MAIL-FORMAT {
    from: noreply@handmadedev.org
reply-to: noreply@handmadedev.org
 subject: $SERVICE $EVENT at $DATE
 message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION
}
SET ALERT team@handmadedev.org only on { nonexist, instance }

CHECK PROCESS caddy PIDFILE /home/caddy/caddy.pid
    GROUP caddy
    START PROGRAM   = "/usr/bin/caddy start --config /home/caddy/Caddyfile --pidfile /home/caddy/caddy.pid" AS UID "caddy"
    STOP PROGRAM    = "/usr/bin/caddy stop" AS UID "caddy"
    RESTART PROGRAM = "/usr/bin/caddy reload --config /home/caddy/Caddyfile" AS UID "caddy"
    MODE ACTIVE

CHECK PROCESS hmn PIDFILE /home/hmn/hmn.pid
    GROUP hmn
    START PROGRAM = "/home/hmn/hmn/server/start.sh" AS UID "hmn"
    STOP PROGRAM  = "/home/hmn/hmn/server/stop.sh"  AS UID "hmn"
    MODE ACTIVE

CHECK PROCESS cinera PIDFILE /home/hmn/hmn/cinera/data/cinera.pid
    GROUP cinera
    START PROGRAM = "/home/hmn/hmn/cinera/start.sh" AS UID "annotations"
    STOP PROGRAM  = "/home/hmn/hmn/cinera/stop.sh"  AS UID "annotations"
    MODE PASSIVE
