Changeset - 4c8232a28452
[Not reviewed]
0 1 0
Brett Smith (brett) - 6 years ago 2017-11-10 16:45:58
brett@sfconservancy.org
website-update: Make sqlite loading more robust.

* Bail on the first error.
* Allow 30 seconds to open a locked table.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
cron/scripts/website-update.sh
Show inline comments
...
 
@@ -12,25 +12,25 @@ DB_SCRIPT=~bkuhn/django-supporters-list.sql
 
git_rev_name() {
 
    git rev-parse --abbrev-ref --symbolic-full-name "$@"
 
}
 

	
 
if ! mkdir "$LOCKDIR"; then
 
    test -d "$LOCKDIR"
 
    exit $?
 
fi
 
trap 'rmdir "$LOCKDIR"' 0 INT TERM QUIT
 

	
 
exitcode=0
 
if [ "$DB_SCRIPT" -nt "$DB_FILE" ]; then
 
    sqlite3 "$DB_FILE" <"$DB_SCRIPT" || exitcode=$?
 
    sqlite3 -bail -cmd ".timeout 30000" "$DB_FILE" <"$DB_SCRIPT" || exitcode=$?
 
fi
 

	
 
# If the checkout is not on the production branch,
 
# assume maintenance is happening and stop.
 
cd "$SITEDIR"
 
if [ "$(git_rev_name HEAD)" != "$PRODUCTION_BRANCH" ]; then
 
    exit "$exitcode"
 
fi
 

	
 
# Abort if the production branch isn't tracking a remote branch.
 
if ! git_upstream="$(git_rev_name '@{upstream}' 2>/dev/null)"; then
 
    exit 3
0 comments (0 inline, 0 general)