saibalajiomg commited on
Commit
168702f
·
verified ·
1 Parent(s): cc0f742

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. .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 to ensure spaces never hit the 48-hour inactivity limit
6
  - cron: '0 6,18 * * *'
7
- workflow_dispatch: # Allow manual triggers from GitHub Actions UI
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 "WARNING: HF_TOKEN secret not set - skipping restart check"
25
  exit 0
26
  fi
27
 
@@ -41,41 +41,60 @@ jobs:
41
  echo " Current status: $STATUS"
42
 
43
  if [ "$STATUS" != "RUNNING" ]; then
44
- echo " Space is not running ($STATUS). Restarting..."
45
  curl -s -X POST \
46
  -H "Authorization: Bearer $HF_TOKEN" \
47
  "https://huggingface.co/api/spaces/$SPACE/restart"
48
- echo " Restart request sent. Waiting 30s for boot..."
49
- sleep 30
50
  else
51
- echo " Space is running - OK"
52
  fi
53
  done
 
 
 
54
 
55
- - name: Ping CustomerCore
56
  run: |
57
- RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 60 https://saibalajiomg-customercore.hf.space/api/v1/keep-alive)
58
- echo "CustomerCore responded with HTTP code: $RESPONSE"
 
 
 
 
 
 
59
 
60
- - name: Ping SupportPulse
61
  run: |
62
- RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 60 https://saibalajiomg-supportpulse.hf.space/)
63
- echo "SupportPulse responded with HTTP code: $RESPONSE"
 
 
 
 
 
 
64
 
65
- - name: Ping ResearchIQ
66
  run: |
67
- RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 60 https://saibalajiomg-researchiq.hf.space/)
68
- echo "ResearchIQ responded with HTTP code: $RESPONSE"
 
 
 
 
 
 
69
 
70
  - name: Prevent GitHub Workflow Suspension
71
  run: |
72
- # On Sundays (day 7), write a timestamp to keepalive_ping.txt and commit it.
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 to prevent workflow suspension [skip ci]" || exit 0
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