#!/bin/sh # Server health check script # Checks if the GraphQL server is responding with a proper health query # Default values SERVER_PORT=${SERVER_PORT:-3000} HEALTH_QUERY='{"query":"query HealthCheck { __typename }"}' # Check if the GraphQL server is responding if ! curl -f -s \ --request POST \ --header "Content-Type: application/json" \ --data "$HEALTH_QUERY" \ "http://localhost:${SERVER_PORT}/graphql" > /dev/null; then echo "GraphQL server not responding on port ${SERVER_PORT}" exit 1 fi # Check if the response contains expected GraphQL structure RESPONSE=$(curl -s \ --request POST \ --header "Content-Type: application/json" \ --data "$HEALTH_QUERY" \ "http://localhost:${SERVER_PORT}/graphql") if ! echo "$RESPONSE" | grep -q '"data"'; then echo "GraphQL server not returning valid response" echo "Response: $RESPONSE" exit 1 fi echo "Server health check passed" exit 0