From 123de0dcb757a0c45d37fbe7a3cd6af5e0c90b53 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Tue, 28 May 2013 18:21:55 -0700 Subject: [PATCH] Adding monit script for watching node real-time server. --- config/monit_node.conf | 19 +++++++++++++++++++ fabfile.py | 5 +++++ media/ios/NewsBlur_Prefix.pch | 4 ++-- utils/kill_node.sh | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 config/monit_node.conf create mode 100755 utils/kill_node.sh diff --git a/config/monit_node.conf b/config/monit_node.conf new file mode 100644 index 000000000..4aa8cab67 --- /dev/null +++ b/config/monit_node.conf @@ -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 real-time updates in last 10 minutes, something is wrong +check file node-newsblur.log with path /srv/newsblur/logs/newsblur.log + if timestamp > 10 minutes then exec "/srv/newsblur/utils/kill_node.sh" + # as uid sclay and gid sclay + +check system node_server + if loadavg (1min) > 12 then exec "/srv/newsblur/utils/kill_node.sh" + # as uid sclay and gid sclay + if loadavg (5min) > 8 then exec "/srv/newsblur/utils/kill_node.sh" + # as uid sclay and gid sclay + diff --git a/fabfile.py b/fabfile.py index 947e67cd5..1bb21a432 100644 --- a/fabfile.py +++ b/fabfile.py @@ -535,6 +535,11 @@ def config_monit_task(): sudo('echo "startup=1" > /etc/default/monit') sudo('/etc/init.d/monit restart') +def config_monit_node(): + put('config/monit_node.conf', '/etc/monit/conf.d/node.conf', use_sudo=True) + 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') diff --git a/media/ios/NewsBlur_Prefix.pch b/media/ios/NewsBlur_Prefix.pch index e127b8a2e..cb0a6f7d9 100644 --- a/media/ios/NewsBlur_Prefix.pch +++ b/media/ios/NewsBlur_Prefix.pch @@ -13,8 +13,8 @@ // #define BACKGROUND_REFRESH_SECONDS -5 #define BACKGROUND_REFRESH_SECONDS -10*60 - #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.com"] -// #define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"] +// #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.com"] + #define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"] #define NEWSBLUR_LINK_COLOR 0x405BA8 #define NEWSBLUR_HIGHLIGHT_COLOR 0xd2e6fd diff --git a/utils/kill_node.sh b/utils/kill_node.sh new file mode 100755 index 000000000..870e5c09f --- /dev/null +++ b/utils/kill_node.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +sudo supervisorctl reload