I have a problem with monit where occasionally Varnish will crash and refuse to start. So Varnish is dead and my webserver is inaccessible. Here's the message from the monit log:
info : 'varnish' stop: /etc/init.d/varnish
info : 'varnish' start: /etc/init.d/varnish
error : monit: Error reading pid from file '/var/run/varnish.pid'
Within the Varnish monitor, I thought of setting an option to restart nginx so it can listen for external requests on port 80 again if something like this happens:
if 3 restarts within 3 cycles
then exec "/etc/init.d/nginx restart"
and timeout
Except when I call that, sometimes nginx stops successfully... but never starts again.
The solutions I've thought of are kind of a hack (kill -9 nginx && /etc/init.d/nginx start) and (killall -9 varnishd && rm -f /var/run/varnish.pid).
I was hoping anyone could offer suggestions to either of the two above problems. Thanks!