Skip to content

Commit c053712

Browse files
authored
Update check_urls.sh (pytorch#10321)
1 parent 85a8e88 commit c053712

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

scripts/check_urls.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@ while IFS=: read -r filepath url; do
1717
printf '\n%s:\n' "$filepath"
1818
last_filepath=$filepath
1919
fi
20-
code=$(curl -gsLm30 -o /dev/null -w "%{http_code}" -I "$url") || code=000
21-
if [ "$code" -ge 400 ]; then
22-
code=$(curl -gsLm30 -o /dev/null -w "%{http_code}" -r 0-0 -A "$user_agent" "$url") || code=000
20+
code=$(curl -gsLm30 --retry 3 --retry-delay 3 --retry-connrefused -o /dev/null -w "%{http_code}" -I "$url") || code=000
21+
if [ "$code" -lt 200 ] || [ "$code" -ge 400 ]; then
22+
code=$(curl -gsLm30 --retry 3 --retry-delay 3 --retry-connrefused -o /dev/null -w "%{http_code}" -r 0-0 -A "$user_agent" "$url") || code=000
2323
fi
24-
if [ "$code" -ge 200 ] && [ "$code" -lt 400 ]; then
25-
printf "${green}%s${reset} ${cyan}%s${reset}\n" "$code" "$url"
26-
else
24+
if [ "$code" -lt 200 ] || [ "$code" -ge 400 ]; then
25+
request_id=$(curl -sS -H 'Accept: application/json' "https://check-host.net/check-http?host=$url&max_nodes=1&node=us3.node.check-host.net" \
26+
| jq -r .request_id)
27+
for _ in {1..3}; do
28+
code=$(curl -sS -H 'Accept: application/json' "https://check-host.net/check-result/$request_id" \
29+
| jq -r -e '.[][0][3]') || code=000
30+
[[ "$code" =~ ^[0-9]+$ ]] || code=000
31+
sleep 3
32+
done
33+
fi
34+
if [ "$code" -lt 200 ] || [ "$code" -ge 400 ]; then
2735
printf "${red}%s${reset} ${yellow}%s${reset}\n" "$code" "$url" >&2
2836
status=1
37+
else
38+
printf "${green}%s${reset} ${cyan}%s${reset}\n" "$code" "$url"
2939
fi
3040
done < <(
3141
git --no-pager grep --no-color -I -P -o \

0 commit comments

Comments
 (0)