Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- .github/workflows/keepalive.yml +38 -19
.github/workflows/keepalive.yml
CHANGED
|
@@ -2,9 +2,9 @@ name: Keep-Alive Ping
|
|
| 2 |
|
| 3 |
on:
|
| 4 |
schedule:
|
| 5 |
-
# Run every 12 hours
|
| 6 |
- cron: '0 6,18 * * *'
|
| 7 |
-
workflow_dispatch:
|
| 8 |
|
| 9 |
permissions:
|
| 10 |
contents: write
|
|
@@ -21,7 +21,7 @@ jobs:
|
|
| 21 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 22 |
run: |
|
| 23 |
if [ -z "$HF_TOKEN" ]; then
|
| 24 |
-
echo "
|
| 25 |
exit 0
|
| 26 |
fi
|
| 27 |
|
|
@@ -41,41 +41,60 @@ jobs:
|
|
| 41 |
echo " Current status: $STATUS"
|
| 42 |
|
| 43 |
if [ "$STATUS" != "RUNNING" ]; then
|
| 44 |
-
echo "
|
| 45 |
curl -s -X POST \
|
| 46 |
-H "Authorization: Bearer $HF_TOKEN" \
|
| 47 |
"https://huggingface.co/api/spaces/$SPACE/restart"
|
| 48 |
-
echo " Restart request sent.
|
| 49 |
-
sleep 30
|
| 50 |
else
|
| 51 |
-
echo "
|
| 52 |
fi
|
| 53 |
done
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
- name: Ping CustomerCore
|
| 56 |
run: |
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
- name: Ping SupportPulse
|
| 61 |
run: |
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
- name: Ping ResearchIQ
|
| 66 |
run: |
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
- name: Prevent GitHub Workflow Suspension
|
| 71 |
run: |
|
| 72 |
-
# On Sundays
|
| 73 |
-
# This repository activity resets GitHub's 60-day cron suspension timer.
|
| 74 |
if [ "$(date +%u)" -eq 7 ]; then
|
| 75 |
echo "Keep-alive tick: $(date -u)" > keepalive_ping.txt
|
| 76 |
git config --local user.email "action@github.com"
|
| 77 |
git config --local user.name "GitHub Action"
|
| 78 |
git add keepalive_ping.txt
|
| 79 |
-
git commit -m "chore: weekly keep-alive tick
|
| 80 |
git push
|
| 81 |
fi
|
|
|
|
| 2 |
|
| 3 |
on:
|
| 4 |
schedule:
|
| 5 |
+
# Run every 12 hours - well within the 48-hour HF sleep timeout
|
| 6 |
- cron: '0 6,18 * * *'
|
| 7 |
+
workflow_dispatch:
|
| 8 |
|
| 9 |
permissions:
|
| 10 |
contents: write
|
|
|
|
| 21 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 22 |
run: |
|
| 23 |
if [ -z "$HF_TOKEN" ]; then
|
| 24 |
+
echo "HF_TOKEN not set - will rely on HTTP pings to wake spaces"
|
| 25 |
exit 0
|
| 26 |
fi
|
| 27 |
|
|
|
|
| 41 |
echo " Current status: $STATUS"
|
| 42 |
|
| 43 |
if [ "$STATUS" != "RUNNING" ]; then
|
| 44 |
+
echo " Restarting via API..."
|
| 45 |
curl -s -X POST \
|
| 46 |
-H "Authorization: Bearer $HF_TOKEN" \
|
| 47 |
"https://huggingface.co/api/spaces/$SPACE/restart"
|
| 48 |
+
echo " Restart request sent."
|
|
|
|
| 49 |
else
|
| 50 |
+
echo " Already running."
|
| 51 |
fi
|
| 52 |
done
|
| 53 |
+
# Give spaces time to boot before pinging
|
| 54 |
+
echo "Waiting 60s for spaces to start..."
|
| 55 |
+
sleep 60
|
| 56 |
|
| 57 |
+
- name: Ping and wake CustomerCore
|
| 58 |
run: |
|
| 59 |
+
echo "Pinging CustomerCore (with retry for cold start)..."
|
| 60 |
+
for i in 1 2 3; do
|
| 61 |
+
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 120 https://saibalajiomg-customercore.hf.space/api/v1/keep-alive)
|
| 62 |
+
echo " Attempt $i: HTTP $RESPONSE"
|
| 63 |
+
if [ "$RESPONSE" -eq 200 ]; then break; fi
|
| 64 |
+
echo " Waiting 30s before retry..."
|
| 65 |
+
sleep 30
|
| 66 |
+
done
|
| 67 |
|
| 68 |
+
- name: Ping and wake SupportPulse
|
| 69 |
run: |
|
| 70 |
+
echo "Pinging SupportPulse (with retry for cold start)..."
|
| 71 |
+
for i in 1 2 3; do
|
| 72 |
+
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 120 https://saibalajiomg-supportpulse.hf.space/)
|
| 73 |
+
echo " Attempt $i: HTTP $RESPONSE"
|
| 74 |
+
if [ "$RESPONSE" -eq 200 ]; then break; fi
|
| 75 |
+
echo " Waiting 30s before retry..."
|
| 76 |
+
sleep 30
|
| 77 |
+
done
|
| 78 |
|
| 79 |
+
- name: Ping and wake ResearchIQ
|
| 80 |
run: |
|
| 81 |
+
echo "Pinging ResearchIQ (with retry for cold start)..."
|
| 82 |
+
for i in 1 2 3; do
|
| 83 |
+
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 120 https://saibalajiomg-researchiq.hf.space/)
|
| 84 |
+
echo " Attempt $i: HTTP $RESPONSE"
|
| 85 |
+
if [ "$RESPONSE" -eq 200 ]; then break; fi
|
| 86 |
+
echo " Waiting 30s before retry..."
|
| 87 |
+
sleep 30
|
| 88 |
+
done
|
| 89 |
|
| 90 |
- name: Prevent GitHub Workflow Suspension
|
| 91 |
run: |
|
| 92 |
+
# On Sundays, auto-commit to prevent GitHub from suspending this cron after 60 days
|
|
|
|
| 93 |
if [ "$(date +%u)" -eq 7 ]; then
|
| 94 |
echo "Keep-alive tick: $(date -u)" > keepalive_ping.txt
|
| 95 |
git config --local user.email "action@github.com"
|
| 96 |
git config --local user.name "GitHub Action"
|
| 97 |
git add keepalive_ping.txt
|
| 98 |
+
git commit -m "chore: weekly keep-alive tick [skip ci]" || exit 0
|
| 99 |
git push
|
| 100 |
fi
|