cleanup_remote_runtime.sh 819 B

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