1

I want monit to check specific process and start it only when the depending filesystem is available.

check process Tomcat with pidfile /path/to/tomcat/TOMCAT.PID 
        depends on abc
        start program = "../scripts/start_tomcat.sh"
        stop program = "../scripts/stop_tomcat.sh  -force"

check filesystem abc with path /path/to/abc
        if does not exist then restart

In that above configuration, when filesystem goes down, monit is repeatedly start and stop the tomcat, which makes 8080 port in listen all the time. I want to make that start program runs only when filesystem is available. Not repeatedly start and stop it.

1 Answers1

0

Here, you defined restart as action on the filesystem, so when the file does not exist, it will mostly propagate the restart action to all depending 'check' rule as state in the documentation:

If a service is restarted, it will first stop any active services that depend on it and after it is started, start all depending services that were active before the restart again.

As state by someone else previously, why would the filesystem goes down ? If that's a mounted directory, best would be to take action to mount again the file system with a custom 'exec action in the rule for the filesystem and let monit start the tomcat through the dependency management rule.

More details at : https://mmonit.com/monit/documentation/monit.html#SERVICE-DEPENDENCIES

DevOps
  • 720
  • 3
  • 15