aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-08-11 15:39:05 +0100
committerSeb Bacon <seb.bacon@gmail.com>2011-08-11 15:43:05 +0100
commiteb616008189c6db73e88a65505e57eabfbfe453c (patch)
tree68a2c064ab00b0d311cb4296c162cd2c6f1cde1c
parent8d75b913cb4b14a143ccc0a418c7af6e7d33d82f (diff)
Compact database regularly. Fixes #127.
-rw-r--r--config/crontab.ugly3
-rw-r--r--config/packages1
-rwxr-xr-xscript/compact-xapian-database16
3 files changed, 20 insertions, 0 deletions
diff --git a/config/crontab.ugly b/config/crontab.ugly
index 5820151a0..ecd3151ff 100644
--- a/config/crontab.ugly
+++ b/config/crontab.ugly
@@ -27,6 +27,9 @@ MAILTO=cron-!!(*= $site *)!!@mysociety.org
0 8 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/alert-not-clarified-request.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/alert-not-clarified-request || echo "stalled?"
2 4 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/check-recent-requests-sent.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/check-recent-requests-sent || echo "stalled?"
45 3 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/stop-new-responses-on-old-requests.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/stop-new-responses-on-old-requests || echo "stalled?"
+# Only root can restart apache
+31 1 * * * root run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/compact-xapian-database.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/compact-xapian-database production || echo "stalled?"
+
# Once a day on all servers
43 2 * * * !!(*= $user *)!! /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/request-creation-graph
diff --git a/config/packages b/config/packages
index 4695ea828..a42785824 100644
--- a/config/packages
+++ b/config/packages
@@ -17,6 +17,7 @@ elinks
unrtf
xlhtml
libxapian-ruby1.8
+xapian-tools
gnuplot-nox
php5-cli
# ttf-bitstream-vera
diff --git a/script/compact-xapian-database b/script/compact-xapian-database
new file mode 100755
index 000000000..5c12b5dae
--- /dev/null
+++ b/script/compact-xapian-database
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+RAILS_ENV=$1
+set -e
+if [ -x /usr/bin/xapian-compact ]; then
+ XAPIAN_DB_DIR="$( cd "$( dirname "$0" )" && pwd )/../vendor/plugins/acts_as_xapian/xapiandbs"
+ OWNER=`stat -c %U $XAPIAN_DB_DIR/$RAILS_ENV`
+ su -c "xapian-compact $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.new" $OWNER
+ mv $XAPIAN_DB_DIR/$RAILS_ENV $XAPIAN_DB_DIR/$RAILS_ENV.tmp
+ mv $XAPIAN_DB_DIR/$RAILS_ENV.new $XAPIAN_DB_DIR/$RAILS_ENV
+ rm -rf $XAPIAN_DB_DIR/$RAILS_ENV.tmp
+ /etc/init.d/apache2 restart
+else
+ echo "Could not find xapian-compact script; have you installed xapian-tools?"
+ exit 1
+fi \ No newline at end of file