diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/Vagrantfile | 23 | ||||
-rw-r--r-- | config/crontab-example | 26 | ||||
-rw-r--r-- | config/environments/development.rb | 11 | ||||
-rw-r--r-- | config/general.yml-example | 4 | ||||
-rw-r--r-- | config/nginx.conf.example | 29 | ||||
-rw-r--r-- | config/packages.debian-squeeze | 39 | ||||
-rw-r--r-- | config/packages.ubuntu-precise | 35 | ||||
-rw-r--r-- | config/purge-varnish-debian.ugly | 2 | ||||
-rwxr-xr-x | config/sysvinit.example | 53 |
9 files changed, 206 insertions, 16 deletions
diff --git a/config/Vagrantfile b/config/Vagrantfile new file mode 100644 index 000000000..4253215fc --- /dev/null +++ b/config/Vagrantfile @@ -0,0 +1,23 @@ +# This Vagrantfile should be used with the --no-color option, e.g. +# vagrant --no-color up +# Then you should be able to visit the site at: +# http://alaveteli.10.10.10.30.xip.io + +Vagrant::Config.run do |config| + config.vm.box = "precise64" + config.vm.box_url = "http://files.vagrantup.com/precise64.box" + config.vm.network :hostonly, "10.10.10.30" + # The bundle install fails unless you have quite a large amount of + # memory; insist on 1.5GiB: + config.vm.customize ["modifyvm", :id, "--memory", 1536] + # Fetch and run the install script: + config.vm.provision :shell, :inline => "wget -O install-site.sh https://raw.github.com/mysociety/commonlib/master/bin/install-site.sh" + config.vm.provision :shell, :inline => "chmod a+rx install-site.sh" + # This is only needed before the install-script branch is merged to + # master: + config.vm.provision :shell, :inline => "sed -i -e 's/BRANCH=master/BRANCH=install-script/' install-site.sh" + config.vm.provision :shell, :inline => "./install-site.sh " \ + "alaveteli " \ + "alaveteli " \ + "alaveteli.10.10.10.30.xip.io" +end diff --git a/config/crontab-example b/config/crontab-example index d2c3f6bd9..366624998 100644 --- a/config/crontab-example +++ b/config/crontab-example @@ -8,33 +8,33 @@ PATH=/usr/local/bin:/usr/bin:/bin MAILTO=cron-!!(*= $site *)!!@mysociety.org # Every 5 minutes -*/5 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/change-xapian-database.lock "/data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/update-xapian-index verbose=true" >> /data/vhost/!!(*= $vhost *)!!/logs/update-xapian-index.log || echo "stalled?" +*/5 * * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/change-xapian-database.lock "!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/update-xapian-index verbose=true" >> !!(*= $vhost_dir *)!!/logs/update-xapian-index.log || echo "stalled?" # Every 10 minutes 5,15,25,35,45,55 * * * * !!(*= $user *)!! /etc/init.d/foi-alert-tracks check 5,15,25,35,45,55 * * * * !!(*= $user *)!! /etc/init.d/foi-purge-varnish check # Once an hour -09 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/alert-comment-on-request.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/alert-comment-on-request || echo "stalled?" +09 * * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/alert-comment-on-request.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/alert-comment-on-request || echo "stalled?" # Only root can read the log files -31 * * * * root run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/load-mail-server-logs.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/load-mail-server-logs || echo "stalled?" +31 * * * * root run-with-lockfile -n !!(*= $vhost_dir *)!!/load-mail-server-logs.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/load-mail-server-logs || echo "stalled?" # Once a day, early morning -23 4 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/delete-old-things.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/delete-old-things || echo "stalled?" -0 6 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/alert-overdue-requests.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/alert-overdue-requests || echo "stalled?" -0 7 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/alert-new-response-reminders.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/alert-new-response-reminders || echo "stalled?" -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?" -55 4 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/update-public-body-stats.lock /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/update-public-body-stats || echo "stalled?" +23 4 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/delete-old-things.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/delete-old-things || echo "stalled?" +0 6 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/alert-overdue-requests.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/alert-overdue-requests || echo "stalled?" +0 7 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/alert-new-response-reminders.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/alert-new-response-reminders || echo "stalled?" +0 8 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/alert-not-clarified-request.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/alert-not-clarified-request || echo "stalled?" +2 4 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/check-recent-requests-sent.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/check-recent-requests-sent || echo "stalled?" +45 3 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/stop-new-responses-on-old-requests.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/stop-new-responses-on-old-requests || echo "stalled?" +55 4 * * * !!(*= $user *)!! run-with-lockfile -n !!(*= $vhost_dir *)!!/update-public-body-stats.lock !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/update-public-body-stats || echo "stalled?" # Only root can restart apache -31 1 * * * root run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/change-xapian-database.lock "/data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/compact-xapian-database production" || echo "stalled?" +31 1 * * * root run-with-lockfile -n !!(*= $vhost_dir *)!!/change-xapian-database.lock "!!(*= $vhost_dir *)!!/!!(*= $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 -48 2 * * * !!(*= $user *)!! /data/vhost/!!(*= $vhost *)!!/!!(*= $vcspath *)!!/script/user-use-graph +43 2 * * * !!(*= $user *)!! !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/request-creation-graph +48 2 * * * !!(*= $user *)!! !!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/user-use-graph # Once a year :) 0 0 1 11 * !!(*= $user *)!! /bin/echo "A year has passed, please update the bank holidays for the Freedom of Information site, thank you." diff --git a/config/environments/development.rb b/config/environments/development.rb index 54ab2977f..a912dd5de 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,9 +16,14 @@ Alaveteli::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_deliveries = true - # Use mailcatcher in development - config.action_mailer.delivery_method = :smtp # so is queued, rather than giving immediate errors - config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } + + if AlaveteliConfiguration::use_mailcatcher_in_development + # Use mailcatcher in development + config.action_mailer.delivery_method = :smtp # so is queued, rather than giving immediate errors + config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } + else + config.action_mailer.delivery_method = :sendmail + end # Writes useful log files to debug memory leaks, of the sort where have # unintentionally kept references to objects, especially strings. diff --git a/config/general.yml-example b/config/general.yml-example index 8e749d9d6..60eb5ae1c 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -205,3 +205,7 @@ MINIMUM_REQUESTS_FOR_STATISTICS: 50 # available locale, you can allow a fallback to the default locale for # listing of public bodies. PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE: false + +# If true, while in development mode, try to send mail by SMTP to port +# 1025 (the port the mailcatcher listens on by default): +USE_MAILCATCHER_IN_DEVELOPMENT: true diff --git a/config/nginx.conf.example b/config/nginx.conf.example new file mode 100644 index 000000000..56e720abb --- /dev/null +++ b/config/nginx.conf.example @@ -0,0 +1,29 @@ +upstream alaveteli { + server 127.0.0.1:3300; +} + +server { + listen 80; + root /var/www/alaveteli/alaveteli/public; + + location / { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Proto http; + proxy_redirect off; + try_files $uri @ruby; + } + + location /download { + internal; + alias /var/www/alaveteli/alaveteli/cache/zips/development/download; + } + + location @ruby { + proxy_pass http://alaveteli; + proxy_set_header Host $http_host; + proxy_set_header X-Sendfile-Type X-Accel-Redirect; + proxy_set_header X-Accel-Mapping /var/www/alaveteli/alaveteli/cache/zips/development/download=/download; + } +} diff --git a/config/packages.debian-squeeze b/config/packages.debian-squeeze new file mode 100644 index 000000000..6cdf2f9d6 --- /dev/null +++ b/config/packages.debian-squeeze @@ -0,0 +1,39 @@ +ruby1.8 +ruby +libruby1.8 +rdoc1.8 +irb1.8 +wv +poppler-utils +pdftk +ghostscript +catdoc +links +elinks +unrtf +xlhtml +xapian-tools +gnuplot-nox +php5-cli +sharutils +unzip +mutt +tnef +gettext +python-yaml +wkhtmltopdf-static +libmagic-dev +libmagickwand-dev +libpq-dev +libxml2-dev +libxslt-dev +uuid-dev +ruby1.8-dev +rubygems/squeeze-backports +rake +build-essential +sqlite3 +libsqlite3-dev +libicu-dev +postgresql +postgresql-client diff --git a/config/packages.ubuntu-precise b/config/packages.ubuntu-precise new file mode 100644 index 000000000..177d504e2 --- /dev/null +++ b/config/packages.ubuntu-precise @@ -0,0 +1,35 @@ +ruby1.9.1 +wv +poppler-utils +pdftk +ghostscript +catdoc +links +elinks +unrtf +xlhtml +xapian-tools +gnuplot-nox +sharutils +unzip +mutt +tnef +gettext +python-yaml +wkhtmltopdf-static +libmagic-dev +libmagickwand-dev +libpq-dev +libxml2-dev +libxslt1-dev +uuid-dev +ruby1.9.1-dev +rubygems +rake +build-essential +ruby-bundler +sqlite3 +libsqlite3-dev +libicu-dev +postgresql +postgresql-client diff --git a/config/purge-varnish-debian.ugly b/config/purge-varnish-debian.ugly index 04458ea78..3f11344f2 100644 --- a/config/purge-varnish-debian.ugly +++ b/config/purge-varnish-debian.ugly @@ -22,6 +22,8 @@ DUSER=!!(*= $user *)!! # RAILS_ENV=your_rails_env # export RAILS_ENV +type varnishadm > /dev/null 2>&1 || exit + trap "" 1 export PIDFILE LOGFILE diff --git a/config/sysvinit.example b/config/sysvinit.example new file mode 100755 index 000000000..443e7c3fb --- /dev/null +++ b/config/sysvinit.example @@ -0,0 +1,53 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: application-thin-alaveteli +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts the Thin web server for the "Alaveteli" site +# Description: The Thin web server for the "Alaveteli" site +### END INIT INFO + +# This example sysvinit script is based on the helpful example here: +# http://richard.wallman.org.uk/2010/02/howto-deploy-a-catalyst-application-using-fastcgi-and-nginx/ + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +SITE_HOME=/var/www/alaveteli +NAME=alaveteli +DESC="Alaveteli app server" +USER=fms + +echo $DAEMON +test -f $DAEMON || exit 0 + +set -e + +start_daemon() { + su -l -c "cd $SITE_HOME/alaveteli && bundle exec thin -d -p 3300 -e development start" $USER +} + +stop_daemon() { + pkill -f thin -u $USER || true +} + +case "$1" in + start) + start_daemon + ;; + stop) + stop_daemon + ;; + reload|restart|force-reload) + stop_daemon + sleep 5 + start_daemon + ;; + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|reload|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 |