cleanup_remote_runtime.sh 644 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. # API base URL
  3. BASE_URL="https://api.all-hands.dev/v0"
  4. # Get the list of runtimes
  5. runtimes=$(curl --silent --location --request GET "${BASE_URL}/runtime/list" \
  6. --header "X-API-Key: ${ALLHANDS_API_KEY}" | jq -r '.runtimes | .[].runtime_id')
  7. # Loop through each runtime and stop it
  8. for runtime_id in $runtimes; do
  9. echo "Stopping runtime: ${runtime_id}"
  10. curl --silent --location --request POST "${BASE_URL}/runtime/stop" \
  11. --header "X-API-Key: ${ALLHANDS_API_KEY}" \
  12. --header "Content-Type: application/json" \
  13. --data-raw "{\"runtime_id\": \"${runtime_id}\"}"
  14. echo
  15. done
  16. echo "All runtimes have been stopped."