Nov 192010

This is a monit recipe for a rails app with 4 Unicorn threads using SOCKET. The app averages a total memory usage of 600 MB.
If it goes over 800 MB send email alert only.
If over 860 MB, reload the app.
Also if it’s using too much CPU, alert by email.

I use unicorn_rails on socket mode with nginx, and preload_app = true.

check process myapp_unicorn 
  with pidfile /var/www/apps/
group unicorn
if totalmem > 800 MB for 2 cycles 
  then alert
if totalmem > 860 MB for 2 cycles 
  then exec "kill -HUP `cat /var/www/apps/`"
if cpu > 40% for 2 cycles then alert
if cpu > 20% for 4 cycles then alert
if failed 
  unixsocket /var/www/apps/ 
  then alert

note: the HUP signal will reload the children processes without reloading code changes. This is fast and desirable.


 Posted by at 7:18 pm  Tagged with:

Sorry, the comment form is closed at this time.

Switch to our mobile site