Created
January 17, 2026 18:36
-
-
Save phiat/0d5d0b15c25cef1c3b3c45072e9d9df5 to your computer and use it in GitHub Desktop.
Demo: sprites.dev sprite stays 'running' instead of going 'warm' after idle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # sprites-sleep-bug-demo.sh | |
| # Demonstrates: sprite stays 'running' instead of going 'warm' after 30s idle | |
| set -e | |
| SPRITE_NAME="sleep-test-$(date +%s)" | |
| API="https://api.sprites.dev/v1/sprites" | |
| : "${SPRITES_TOKEN:?Set SPRITES_TOKEN env var}" | |
| echo "=== Creating sprite: $SPRITE_NAME ===" | |
| curl -sX POST "$API" \ | |
| -H "Authorization: Bearer $SPRITES_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"name\":\"$SPRITE_NAME\"}" | jq -r '.status // .' | |
| echo -e "\n=== Touching sprite (quick exec) ===" | |
| # Brief touch - just run 'true' to wake it, then exit immediately | |
| curl -sX POST "$API/$SPRITE_NAME/exec" \ | |
| -H "Authorization: Bearer $SPRITES_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"command":["true"]}' --max-time 5 || true | |
| echo -e "\n=== Monitoring status (expecting 'warm' after ~30s) ===" | |
| check_status() { | |
| curl -s "$API/$SPRITE_NAME" -H "Authorization: Bearer $SPRITES_TOKEN" | jq -r '.status' | |
| } | |
| for secs in 45 60 120; do | |
| if [[ $secs -eq 45 ]]; then | |
| echo "Waiting 45s..." | |
| sleep 45 | |
| elif [[ $secs -eq 60 ]]; then | |
| echo "Waiting 15s more..." | |
| sleep 15 | |
| else | |
| echo "Waiting 60s more..." | |
| sleep 60 | |
| fi | |
| STATUS=$(check_status) | |
| echo "[${secs}s] status: $STATUS" | |
| if [[ "$STATUS" == "warm" ]]; then | |
| echo "SUCCESS: sprite went warm" | |
| break | |
| fi | |
| done | |
| if [[ "$STATUS" != "warm" ]]; then | |
| echo "BUG: sprite still '$STATUS' after 120s idle" | |
| fi | |
| echo -e "\n=== Cleanup ===" | |
| curl -sX DELETE "$API/$SPRITE_NAME" -H "Authorization: Bearer $SPRITES_TOKEN" | |
| echo "Deleted $SPRITE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment