Spaces:
Sleeping
Sleeping
Add restart_space.sh script for manual HF Space restart
Browse files- scripts/restart_space.sh +24 -0
scripts/restart_space.sh
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Restart HuggingFace Space after code push
|
| 3 |
+
|
| 4 |
+
SPACE_ID="nice-bill/agent-arena"
|
| 5 |
+
|
| 6 |
+
echo "Restarting HF Space: $SPACE_ID"
|
| 7 |
+
|
| 8 |
+
# Using HF CLI to restart the Space
|
| 9 |
+
if command -v hf &> /dev/null; then
|
| 10 |
+
hf space restart "$SPACE_ID"
|
| 11 |
+
echo "Space restart requested via HF CLI"
|
| 12 |
+
elif [ -n "$HF_TOKEN" ]; then
|
| 13 |
+
# Using curl to call HF API
|
| 14 |
+
curl -X POST "https://huggingface.co/api/spaces/$SPACE_ID/submit" \
|
| 15 |
+
-H "Authorization: Bearer $HF_TOKEN" \
|
| 16 |
+
-H "Content-Type: application/json" \
|
| 17 |
+
-d '{"action": "restart"}'
|
| 18 |
+
echo "Space restart requested via API"
|
| 19 |
+
else
|
| 20 |
+
echo "No HF CLI or HF_TOKEN found."
|
| 21 |
+
echo "Please restart manually: https://huggingface.co/spaces/$SPACE_ID"
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
echo "Done!"
|