diff --git a/scripts/matches/killall.sh b/scripts/matches/killall.sh index b3c0876..efb7327 100755 --- a/scripts/matches/killall.sh +++ b/scripts/matches/killall.sh @@ -15,13 +15,17 @@ CLUSTER="$(tofu -chdir="$ENV_DIR" output -raw match_cluster_name)" INSTANCE="$(tofu -chdir="$ENV_DIR" output -raw api_instance_id)" tasks="$(aws ecs list-tasks --cluster "$CLUSTER" --query 'taskArns[]' --output text | xargs)" +failed=0 if [ -z "$tasks" ]; then echo "no running match tasks" else for task in $tasks; do aws ecs stop-task --cluster "$CLUSTER" --task "$task" \ - --reason "killall: operator stop" --query 'task.taskArn' --output text + --reason "killall: operator stop" --query 'task.taskArn' --output text \ + || { echo "WARN: failed to stop task $task" >&2; failed=$((failed + 1)); } done + [ "$failed" -eq 0 ] \ + || echo "WARN: failed to stop $failed of $(wc -w <<<"$tasks") task(s); the rest were stopped" >&2 fi # AWS-StartNonInteractiveCommand rather than send-command's AWS-RunShellScript. @@ -43,3 +47,5 @@ parameters="$(jq -n --arg command "$remote" '{command: [$command]}')" aws ssm start-session --target "$INSTANCE" \ --document-name AWS-StartNonInteractiveCommand \ --parameters "$parameters" + +[ "$failed" -eq 0 ]