killserver.sh 416 B

12345678910111213141516171819
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. PORT="${EPHEMERIS_PORT:-7015}"
  4. PIDS="$(lsof -ti tcp:"$PORT" || true)"
  5. if [ -z "$PIDS" ]; then
  6. echo "No listeners found on port $PORT"
  7. exit 0
  8. fi
  9. echo "Stopping listeners on port $PORT: $PIDS"
  10. kill $PIDS || true
  11. sleep 1
  12. PIDS="$(lsof -ti tcp:"$PORT" || true)"
  13. if [ -n "$PIDS" ]; then
  14. echo "Force-killing remaining listeners on port $PORT: $PIDS"
  15. kill -9 $PIDS || true
  16. fi