killserver.sh 302 B

123456789101112131415
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. PORT="${1:-8590}"
  4. PIDS="$(lsof -ti tcp:"$PORT" 2>/dev/null || true)"
  5. if [ -n "${PIDS}" ]; then
  6. kill ${PIDS} 2>/dev/null || true
  7. sleep 1
  8. fi
  9. PIDS="$(lsof -ti tcp:"$PORT" 2>/dev/null || true)"
  10. if [ -n "${PIDS}" ]; then
  11. kill -9 ${PIDS} 2>/dev/null || true
  12. fi