-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'purge-requests' into develop
- Loading branch information
Showing
29 changed files
with
399 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ TAGS | |
/public/download | ||
/public/*theme | ||
/vendor/bundle | ||
.bundle | ||
.bundle | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# models/purge_request.rb: | ||
# A queue of URLs to purge | ||
# | ||
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. | ||
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ | ||
# | ||
|
||
class PurgeRequest < ActiveRecord::Base | ||
def self.purge_all | ||
done_something = false | ||
for item in PurgeRequest.all() | ||
item.purge | ||
done_something = true | ||
end | ||
return done_something | ||
end | ||
|
||
def self.purge_all_loop | ||
# Run purge_all in an endless loop, sleeping when there is nothing to do | ||
while true | ||
sleep_seconds = 1 | ||
while !purge_all | ||
sleep sleep_seconds | ||
sleep_seconds *= 2 | ||
sleep_seconds = 30 if sleep_seconds > 30 | ||
end | ||
end | ||
end | ||
|
||
def purge | ||
config = MySociety::Config.load_default() | ||
varnish_url = config['VARNISH_HOST'] | ||
result = quietly_try_to_purge(varnish_url, self.url) | ||
if result == "200" | ||
self.delete() | ||
end | ||
end | ||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
# | ||
### BEGIN INIT INFO | ||
# Provides: purge-varnish | ||
# Required-Start: $local_fs $syslog | ||
# Required-Stop: $local_fs $syslog | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: purge-varnish is a daemon running the Alaveteli email alerts | ||
# Description: purge-varnish send Alaveteli email alerts as required | ||
### END INIT INFO | ||
# | ||
# !!(*= $daemon_name *)!! Start the Alaveteli email alert daemon | ||
|
||
NAME=!!(*= $daemon_name *)!! | ||
DAEMON=/data/vhost/!!(*= $vhost *)!!/alaveteli/script/runner | ||
DAEMON_ARGS="--daemon PurgeRequest.purge_all_loop" | ||
PIDFILE=/data/vhost/!!(*= $vhost *)!!/purge-varnish.pid | ||
LOGFILE=/data/vhost/!!(*= $vhost *)!!/logs/purge-varnish.log | ||
DUSER=!!(*= $user *)!! | ||
|
||
trap "" 1 | ||
|
||
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 --oknodo --pidfile "$PIDFILE" | ||
} | ||
|
||
restart() { stop; start; } | ||
|
||
case "$1" in | ||
check) | ||
quietly_start_daemon | ||
if [ $? -ne 1 ] | ||
then | ||
echo "Alaveteli alert daemon was not running; now restarted" | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
;; | ||
|
||
start) | ||
echo -n "Starting Alaveteli alert daemon: $NAME" | ||
start_daemon | ||
;; | ||
|
||
stop) | ||
echo -n "Stopping Alaveteli alert daemon: $NAME" | ||
stop_daemon | ||
;; | ||
|
||
restart) | ||
echo -n "Restarting Alaveteli alert daemon: $NAME" | ||
stop_daemon | ||
start_daemon | ||
;; | ||
|
||
*) | ||
echo "Usage: /etc/init.d/$NAME {start|stop|restart|check}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
if [ $? -eq 0 ]; then | ||
echo . | ||
exit 0 | ||
else | ||
echo " failed" | ||
exit 1 | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,3 +124,4 @@ EXCEPTION_NOTIFICATIONS_TO: | |
|
||
MAX_REQUESTS_PER_USER_PER_DAY: 2 | ||
|
||
VARNISH_HOST: varnish.localdomain |
Oops, something went wrong.
d6a5e30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes issue #436