I want to restart a process monitored by monit, when the checksum of a file failed. Currently i use
check process prosody with pidfile /var/run/prosody/prosody.pid
depends certificate_file
start program "/etc/init.d/prosody start"
stop program "/etc/init.d/prosody stop"
restart program "/etc/init.d/prosody restart"
check file certificate_file with path /etc/prosody/certs/fullchain.pem
if changed checksum then exec "/usr/bin/monit restart prosody"
But i would like to have some command like if changed checksum then restart prosody
instead of using the monit binary via exec
.
The restart
action seems to be limited to restart the currently monitored process, so an action in a check file
block doesn't do anything.
Simply put action restart
Event restart will be propagated to all dependency with log similar to
Be aware that Monit will continue to trigger event again and again with this configuration -> so trigger restart continuously.
Also it seems, start and stop action must to be specified else nothing is done (could be a bug). (Tested with monit 5.14)
EDIT : With an upgraded Monit version 5.21.0, the behavior is way better and there is not endless restart loop