furt/scripts/health-check.sh

41 lines
1,014 B
Bash
Raw Normal View History

#!/bin/sh
# scripts/health-check.sh - Basic health check for furt service
set -e
# Default values
HOST="127.0.0.1"
PORT="7811"
# Parse command line arguments
while [ $# -gt 0 ]; do
case "$1" in
--host) HOST="$2"; shift 2 ;;
--port) PORT="$2"; shift 2 ;;
*) echo "Usage: $0 [--host HOST] [--port PORT]"; exit 1 ;;
esac
done
echo "Checking furt health at $HOST:$PORT..."
# Check if port is listening
if command -v curl >/dev/null 2>&1; then
if curl -s "http://$HOST:$PORT/health" > /tmp/health_response; then
echo "Health check successful:"
cat /tmp/health_response | sed 's/^/ /'
rm -f /tmp/health_response
else
echo "Health check failed - service not responding"
exit 1
fi
else
echo "Warning: curl not available, using basic port check"
if nc -z "$HOST" "$PORT" 2>/dev/null; then
echo "Port $PORT is listening on $HOST"
else
echo "Port $PORT is not accessible on $HOST"
exit 1
fi
fi