Adding monit for gunicorn + kill gunicorn script for doing the dirty work.

This commit is contained in:
Samuel Clay 2012-12-10 10:49:36 -08:00
parent 3019cb39a7
commit 36377040e3
4 changed files with 29 additions and 1 deletions

19
config/monit_app.conf Normal file
View file

@ -0,0 +1,19 @@
set daemon 120
set logfile /var/log/monit.log
set eventqueue
basedir /var/monit # set the base directory where events will be stored
slots 100 # optionally limit the queue size
# If no feeds have been fetched in the last 10 minutes, something is wrong
check file app-newsblur.log with path /srv/newsblur/logs/newsblur.log
if timestamp > 10 minutes then exec "/srv/newsblur/utils/kill_gunicorn.sh"
# as uid sclay and gid sclay
check system app_server
if loadavg (1min) > 12 then exec "/srv/newsblur/utils/kill_gunicorn.sh"
# as uid sclay and gid sclay
if loadavg (5min) > 8 then exec "/srv/newsblur/utils/kill_gunicorn.sh"
# as uid sclay and gid sclay

View file

@ -7,7 +7,7 @@ set eventqueue
slots 100 # optionally limit the queue size
# If no feeds have been fetched in the last 10 minutes, something is wrong
check file newsblur.log with path /srv/newsblur/logs/newsblur.log
check file task-newsblur.log with path /srv/newsblur/logs/newsblur.log
if timestamp > 10 minutes then exec "/srv/newsblur/utils/kill_celery.sh"
# as uid sclay and gid sclay

6
fabfile.py vendored
View file

@ -313,6 +313,7 @@ def setup_app():
configure_node()
pre_deploy()
deploy()
config_monit_app()
def setup_db():
setup_common()
@ -463,6 +464,11 @@ def config_monit_task():
sudo('echo "startup=1" > /etc/default/monit')
sudo('/etc/init.d/monit restart')
def config_monit_app():
put('config/monit_app.conf', '/etc/monit/conf.d/gunicorn.conf', use_sudo=True)
sudo('echo "startup=1" > /etc/default/monit')
sudo('/etc/init.d/monit restart')
def config_monit_db():
put('config/monit_db.conf', '/etc/monit/conf.d/celery.conf', use_sudo=True)
sudo('echo "startup=1" > /etc/default/monit')

3
utils/kill_gunicorn.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
ps aux | grep gunicorn | egrep -v grep | awk '{print $2}' | xargs kill -9