A supervisor that quietly restarts a service is doing its job and hiding the problem, so a memory leak becomes a daily restart that nobody knows about.
check process php-fpm with pidfile /run/php/php7.3-fpm.pid
start program = "/bin/systemctl start php7.3-fpm"
stop program = "/bin/systemctl stop php7.3-fpm"
if totalmem > 1200 MB for 3 cycles then restart
if 3 restarts within 10 cycles then alert
set mailserver localhost
set alert [email protected]
The second condition is the one that matters: the first keeps the site up and the second tells somebody it has been keeping the site up. Three restarts in ten cycles is a service that is not healthy, and without the alert that is indistinguishable from a service that has never restarted. Monit’s value over systemd’s own restart handling is exactly this — conditions on memory and response time rather than only on the process having exited.