Skip to content

Commit

Permalink
subscribe directly to activemq
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed May 7, 2024
1 parent 8352833 commit f1a6028
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
36 changes: 22 additions & 14 deletions examples/cache-warmer/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@

set -eou pipefail

mygrep() {
# mac OS needs ggrep for the -P flag
if command -v ggrep &>/dev/null; then
ggrep "$@"
else
grep "$@"
fi
}

# how many cURL commands to run in parallel
PARALLEL_EXECUTIONS=3

# Base URL of the sitemap.xml file
BASE_URL="https://$DOMAIN/sitemap.xml"
BASE_URL="$DRUPAL_URL/sitemap.xml"
PAGE=1

process_url() {
local URL="$1"
local COUNT=0
echo "Crawling: $URL"
REDIRECT_URL=$(curl -w "%{redirect_url}" --silent -o /dev/null "$URL")
while [ "$REDIRECT_URL" != "" ]; then
REDIRECT_URL=$(curl -w "%{redirect_url}" --silent -o /dev/null "$REDIRECT_URL?cache-warmer=1")
COUNT=$((COUNT + 1))
if [ "$COUNT" -gt 5 ]; then
break
fi
fi
}

while true; do
NEXT_PAGE_URL="$BASE_URL?page=$PAGE"
STATUS=$(curl -w '%{http_code}' \
Expand All @@ -26,7 +31,7 @@ while true; do
"${NEXT_PAGE_URL}")

if [ "${STATUS}" -eq 200 ]; then
mapfile -t URLS < <(mygrep -oP '<loc>\K[^<]+' links.xml)
mapfile -t URLS < <(grep -oP '<loc>\K[^<]+' links.xml)
while [ "${#URLS[@]}" -gt 0 ]; do
for ((i = 0; i < PARALLEL_EXECUTIONS; i++)); do
array_length=${#URLS[@]}
Expand All @@ -37,7 +42,7 @@ while true; do
break
fi
echo "Crawling: $URL"
curl --silent -o /dev/null "${URL}" &
process_url "$URL?cache-warmer=1" &
job_ids+=($!)
done

Expand All @@ -47,19 +52,22 @@ while true; do
done

PAGE=$((PAGE + 1))
if [ PAGE -gt 100 ]; then
break
fi
else
break
fi
done

rm -f links.xml

curl -v "https://$DOMAIN/api/v1/paged-content" > pc.json
curl -v "$DRUPAL_URL/api/v1/paged-content" > pc.json

mapfile -t NIDS < <(jq -r '.[]' pc.json)
for NID in "${NIDS[@]}"; do
echo "Processing: $NID"
curl -s -o /dev/null "https://$DOMAIN/node/$NID/book-manifest?cache-warmer=1"
curl -s -o /dev/null "$DRUPAL_URL/node/$NID/book-manifest?cache-warmer=1"
done

rm -f pc.json
7 changes: 1 addition & 6 deletions examples/cache-warmer/scyllaridae.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
allowedMimeTypes: [
"*"
]
cmdByMimeType:
default:
cmd: "/app/cmd.sh"
queueName: islandora-cache-warmer

0 comments on commit f1a6028

Please sign in to comment.