We have the following monit config which restarts tomcat if unable to connect to it:
check host Tomcat-Foo with address localhost
stop program = "/usr/bin/systemctl stop tomcat.service"
start program = "/usr/bin/systemctl start tomcat.service" with timeout 360 seconds
if failed host localhost
port 8081
protocol http
request "/foo/"
for 3 times within 5 cycles
then alert
The problem is that it takes quite a while to start up, and monit seems to keep checking. This means that while tomcat is starting up, monit seems to think it is down "again" and initiate another restart, turning it into a restart loop.
Is there an easy way to have monit pause/disable the checking until tomcat is in fact back up again?
Alternatively if this config should look completely different so it wasn't an issue to begin with?