aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/alert-tracks-debian.ugly57
-rw-r--r--config/boot.rb21
-rw-r--r--config/crontab.ugly4
-rw-r--r--config/environment.rb2
4 files changed, 60 insertions, 24 deletions
diff --git a/config/alert-tracks-debian.ugly b/config/alert-tracks-debian.ugly
index 6dfa811a4..e4cc12b38 100644
--- a/config/alert-tracks-debian.ugly
+++ b/config/alert-tracks-debian.ugly
@@ -13,33 +13,60 @@
# !!(*= $daemon_name *)!! Start the WhatDoTheyKnow email alert daemon
NAME=!!(*= $daemon_name *)!!
-DAEMON=/data/vhost/!!(*= $vhost *)!!/alaveteli/script/alert-tracks-daemon
+DAEMON=/data/vhost/!!(*= $vhost *)!!/alaveteli/script/runner
+DAEMON_ARGS="--daemon TrackMailer.alert_tracks_loop"
PIDFILE=/data/vhost/!!(*= $vhost *)!!/alert-tracks.pid
+LOGFILE=/data/vhost/!!(*= $vhost *)!!/logs/alert-tracks.log
DUSER=!!(*= $user *)!!
trap "" 1
-export PIDFILE
+export PIDFILE LOGFILE
+
+quietly_start_daemon() {
+ /sbin/start-stop-daemon --quiet --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS
+}
+
+start_daemon() {
+ /sbin/start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS
+}
+
+stop_daemon() {
+ /sbin/start-stop-daemon --stop --pidfile "$PIDFILE"
+}
+
+restart() { stop; start; }
case "$1" in
+ check)
+ quietly_start_daemon
+ if [ $? -ne 1 ]
+ then
+ echo "WhatDoTheyKnow alert daemon was not running; now restarted"
+ exit 1
+ else
+ exit 0
+ fi
+ ;;
+
start)
- echo -n "Starting WhatDoTheyKnow alert daemon: $NAME"
- start-stop-daemon --start --pidfile $PIDFILE --chuid $DUSER --exec $DAEMON > /dev/null
- ;;
-
+ echo -n "Starting WhatDoTheyKnow alert daemon: $NAME"
+ start_daemon
+ ;;
+
stop)
- echo -n "Stopping WhatDoTheyKnow alert daemon: $NAME"
- start-stop-daemon --stop --pidfile $PIDFILE --oknodo
- ;;
-
+ echo -n "Stopping WhatDoTheyKnow alert daemon: $NAME"
+ stop_daemon
+ ;;
+
restart)
- echo -n "Restarting WhatDoTheyKnow alert daemon: $NAME"
- start-stop-daemon --stop --pidfile $PIDFILE --oknodo
- start-stop-daemon --start --pidfile $PIDFILE --chuid $DUSER --exec $DAEMON > /dev/null
- ;;
+ echo -n "Restarting WhatDoTheyKnow alert daemon: $NAME"
+ stop_daemon
+ start_daemon
+ ;;
*)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
+ echo "Usage: /etc/init.d/$NAME {start|stop|restart|check}"
exit 1
;;
esac
diff --git a/config/boot.rb b/config/boot.rb
index 30e4851a5..90fd9cd4d 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -54,6 +54,7 @@ module Rails
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
end
end
@@ -71,13 +72,17 @@ module Rails
gem 'rails'
end
rescue Gem::LoadError => load_error
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
- exit 1
+ if load_error.message =~ /Could not find RubyGem rails/
+ STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ else
+ raise
+ end
end
class << self
def rubygems_version
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ Gem::RubyGemsVersion rescue nil
end
def gem_version
@@ -91,15 +96,16 @@ module Rails
end
def load_rubygems
+ min_version = '1.3.2'
require 'rubygems'
- unless rubygems_version >= '0.9.4'
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
@@ -115,5 +121,8 @@ module Rails
end
end
+
+
# All that for this:
Rails.boot!
+
diff --git a/config/crontab.ugly b/config/crontab.ugly
index 9193899af..5820151a0 100644
--- a/config/crontab.ugly
+++ b/config/crontab.ugly
@@ -11,8 +11,8 @@ MAILTO=cron-!!(*= $site *)!!@mysociety.org
# Every 5 minutes
*/5 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/update-xapian-index.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/update-xapian-index || echo "stalled?"
-# # Every 10 minutes
-# 5,15,25,35,45,55 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/alert-tracks.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/alert-tracks || echo "stalled?"
+# Every 10 minutes
+5,15,25,35,45,55 * * * * !!(*= $user *)!! /etc/init.d/foi-alert-tracks check
# Once an hour
39 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/alert-overdue-requests.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/alert-overdue-requests || echo "stalled?"
diff --git a/config/environment.rb b/config/environment.rb
index 33be4a060..28598a9ef 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -6,7 +6,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')