Skip to content

Commit

Permalink
www: log cdn purge calls (#2269)
Browse files Browse the repository at this point in the history
* www: log cdn purge calls

Ref: #2264
  • Loading branch information
rvagg authored Apr 10, 2020
1 parent ed0c66d commit 3a9a24f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ansible/www-standalone/resources/scripts/build-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ docker run \
-v /home/nodejs/.npm:/npm/ \
node:latest \
bash -c " \
apt-get update && apt-get install -y rsync && \
addgroup nodejs --gid ${nodeuid} && \
adduser nodejs --uid ${nodeuid} --gid ${nodegid} --gecos nodejs --disabled-password && \
su nodejs -c ' \
Expand All @@ -57,4 +58,4 @@ docker run \

rsync -avz --delete --exclude .git ${clonedir}/${rsync_from} /home/www/${site}/

/home/nodejs/queue-cdn-purge.sh $site
/home/nodejs/queue-cdn-purge.sh $site build-site
4 changes: 4 additions & 0 deletions ansible/www-standalone/resources/scripts/cdn-purge.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ if ! [ -f /tmp/cdnpurge.$site ]; then
exit 0
fi

reason="$(cat /tmp/cdnpurge.$site | tr '\n' ' ')"

rm -f /tmp/cdnpurge.$site

# list zones:
Expand All @@ -36,6 +38,8 @@ rm -f /tmp/cdnpurge.$site
# -H "X-Auth-Email: ${api_email}" \
# -H "X-Auth-Key: ${api_key}"

echo "$(date -u --iso-8601=s), ${site}, ${reason}" >> /home/nodejs/cdn-purge.log

# purge full cache
curl -X DELETE \
"https://api.cloudflare.com/client/v4/zones/${zone_id}/purge_cache" \
Expand Down
4 changes: 2 additions & 2 deletions ansible/www-standalone/resources/scripts/queue-cdn-purge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -e
site=$1

if [ "X$site" != "Xiojs" ] && [ "X$site" != "Xnodejs" ]; then
echo "Usage: queue-cdn-purge.sh < iojs | nodejs >"
echo "Usage: queue-cdn-purge.sh < iojs | nodejs > [reason]"
exit 1
fi

umask 000
touch /tmp/cdnpurge.$site
echo ${2:-unknown} >> /tmp/cdnpurge.$site
9 changes: 8 additions & 1 deletion ansible/www-standalone/tools/promote/_promote.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e

__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [ -z ${srcdir+x} ]; then
Expand All @@ -19,6 +21,7 @@ fi

site=$1
version=$2
purge=no

for subdir in $(cd $srcdir && ls); do

Expand All @@ -39,6 +42,7 @@ for subdir in $(cd $srcdir && ls); do
cp -a "${srcdir}/${subdir}/${doneref}" "${dstdir}/${subdir}/${doneref}"
rm -rf "${srcdir}/${subdir}/${doneref}"
resha=yes
purge=yes
fi

rm -f "${srcdir}/${subdir}/${donefile}"
Expand All @@ -49,7 +53,10 @@ for subdir in $(cd $srcdir && ls); do
${__dirname}/_resha.sh $site $dstdir $subdir
fi

/home/nodejs/queue-cdn-purge.sh $site
fi

done

if [ "$purge" == "yes" ]; then
/home/nodejs/queue-cdn-purge.sh $site promote
fi
2 changes: 1 addition & 1 deletion ansible/www-standalone/tools/promote/resha_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ fi

${__dirname}/_resha.sh $site $dstdir $2

/home/nodejs/queue-cdn-purge.sh $site
/home/nodejs/queue-cdn-purge.sh $site resha_release

0 comments on commit 3a9a24f

Please sign in to comment.