Skip to content

Commit 7f50bc0

Browse files
committed
Perf: skip blank urls.cfg lines and add curl timeouts
Made-with: Cursor
1 parent 6b8cad1 commit 7f50bc0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

scripts/health-check.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ urlsConfig="public/urls.cfg"
1414
echo "Reading $urlsConfig"
1515
while IFS='=' read -r key url
1616
do
17+
# Skip empty lines and invalid entries
18+
key="$(echo "${key:-}" | xargs)"
19+
url="$(echo "${url:-}" | xargs)"
20+
if [ -z "$key" ] || [ -z "$url" ]; then
21+
continue
22+
fi
1723
echo " $key=$url"
1824
KEYSARRAY+=("$key")
1925
URLSARRAY+=("$url")
@@ -67,7 +73,10 @@ do
6773
# Check service status
6874
for i in {1..3}
6975
do
70-
response=$(curl -o /dev/null -s -w '%{http_code} %{time_total}' --silent --output /dev/null "$url")
76+
# Timeouts prevent long hangs from making the workflow exceed the schedule interval.
77+
# - connect-timeout: max seconds to establish connection
78+
# - max-time: max total seconds for the request
79+
response=$(curl --connect-timeout 5 --max-time 15 -o /dev/null -s -w '%{http_code} %{time_total}' --silent --output /dev/null "$url")
7180
http_code=$(echo "$response" | cut -d ' ' -f 1)
7281
time_total=$(echo "$response" | cut -d ' ' -f 2)
7382
echo " $http_code $time_total"

0 commit comments

Comments
 (0)