Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

www: log cdn purge calls #2269

Merged
merged 2 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 && \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a holdover from some website publish debugging we were doing a few months ago, changed on server but not in ansible, I'm unsure if this is necessary but it's there for now!

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' ' ')"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this file was a zero-length signal file, now it should contain a "reason", but it may also contain multiple reasons if more than one request was made before we check it, hence the flattening of multiple lines into one. We use this in the log, below.


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