I have monit configuration like this:
check process unicorn
with pidfile /tmp/pids/unicorn.0.pid
start program = "/etc/init.d/unicorn start"
stop program = "/etc/init.d/unicorn stop"
restart program = "/etc/init.d/unicorn reload"
if mem is greater than 250.0 MB for 2 cycles then restart
if cpu is greater than 22% for 3 cycles then alert
if cpu is greater than 25% for 2 cycles then restart
But look like whenever monit tries to reload the app (e.g due to memory > 250MB), it issues a stop and then a start, rather than use the restart program. Is there a way to tell monit to run the restart instead? Since issue a stop and a start cause the website to goes down for some moment.
I'm seeing the same problem as you reported. I don't know why the 'restart program' is not used to do a restart. However, the workaround I'm using is this:
Note that I left the 'if mem' check so that it will do a stop/start. This is because I presume that the reload probably won't help if you have a memory leak thus a stop/start is likely necessary. But tweak as you see fit.
Short of digging into the monit source code and fixing it (or installing a newer version and finding out if it is already fixed) this is probably your best option.
Which version of monit are you using ?
you syntax for restart seems legit
did you check the web interface to ensure configuration is parsed as attended ?
documentation states