Monitoring Coda - Automatic Restarts

Occasionally the coda daemon will crash. To keep your node running you may want to use a tool to restart the daemon.

There are many tools that do this (monit, supervisord, systemd, daemontools).

This document describes how we currently use Monit to monitor and restart our daemons as needed.

If you are new to monit, this Digitial Ocean Tutorial is an excellent resource. You can also use our code below to get you most of the way there.

We have two configuration files for monit. One for the main monit daemon. One to keep an eye on coda specifically.

Our Monit Config is applied in Ansible, but here’s what it looks like.

# Stripped down config - /etc/monit/monitrc
set daemon 120            # check services at 2-minute intervals
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 # set the base directory where events will be stored
    slots 100                     # optionally limit the queue size
set httpd port 2812 and
    use address localhost  # only accept connection from localhost
    allow localhost        # allow localhost to connect to the server and
    allow admin:monit      # require user 'admin' with password 'monit'
include /etc/monit/conf.d/*
include /etc/monit/conf-enabled/*


# Coda file - /etc/monit/conf.d/coda-daemon
CHECK PROCESS coda MATCHING "coda daemon"
    start program = "/home/admin/"
        as uid "admin" and gid "admin"
    stop program = "/home/admin/scripts/"
        as uid "admin" and gid "admin"

You may use a different user names on your machine and have different scripts.

You don’t have to have a ‘stop program’ and a simple start program might just be
CODA_PRIVKEY_PASS=mypass coda daemon -peer

Our ‘start’ script

Our ‘stop’ script.

1 Like