I am using monit to monitor my WEB service. Everything went OK until monit process was killed by the system. There is a part of monit log file showing the issue
To have monit automatically launched at startup and restarted on failure I added upstart config for monit (I am running Ubuntu 14.04), that looks like this:
# This is an upstart script to keep monit running.
# To install disable the old way of doing things:
#
# /etc/init.d/monit stop && update-rc.d -f monit remove
#
# then put this script here:
#
# /etc/init/monit.conf
#
# and reload upstart configuration:
#
# initctl reload-configuration
#
# You can manually start and stop monit like this:
#
# start monit
# stop monit
#
description "Monit service manager"
limit core unlimited unlimited
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
expect daemon
respawn
exec /usr/bin/monit -c /etc/monitrc
pre-stop exec /usr/bin/monit -c /etc/monitrc quit
When I reboot the system monit is not running.
sudo monit status
$ monit: Status not available -- the monit daemon is not running
How can I configure upstart to keep monit running and monitored?
I had the wrong path to the config file in the start monit command. The correct commands are
exec /usr/bin/monit -c /etc/monit/monitrc
pre-stop exec /usr/bin/monit -c /etc/monit/monitrc quit
It starts monit as daemon and restarts when I kill it:
ps aux | grep monit
root 2173 0.0 0.1 104348 1332 ? Sl 04:13 0:00 /usr/bin/monit -c /etc/monit/monitrc
sudo kill -9 2173
ps aux | grep monit
root 2184 0.0 0.1 104348 1380 ? Sl 04:13 0:00 /usr/bin/monit -c /etc/monit/monitrc