Permalink
Browse files

Adding monit for gunicorn + kill gunicorn script for doing the dirty …

…work.
  • Loading branch information...
1 parent 3019cb3 commit 36377040e37c4d4e14e3022c9abf4237af089a19 @samuelclay committed Dec 10, 2012
Showing with 29 additions and 1 deletion.
  1. +19 −0 config/monit_app.conf
  2. +1 −1 config/monit_task.conf
  3. +6 −0 fabfile.py
  4. +3 −0 utils/kill_gunicorn.sh
View
@@ -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
@@ -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
View
@@ -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')
View
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ps aux | grep gunicorn | egrep -v grep | awk '{print $2}' | xargs kill -9

0 comments on commit 3637704

Please sign in to comment.