| # Kill any process bound to port 3004 so the nova-sim server can be restarted cleanly. | |
| set -euo pipefail | |
| if ! command -v lsof >/dev/null 2>&1; then | |
| echo "lsof is required but missing" >&2 | |
| exit 1 | |
| fi | |
| PIDS=$(lsof -ti tcp:3004 2>/dev/null || true) | |
| if [[ -z "$PIDS" ]]; then | |
| echo "No server listening on port 3004" | |
| exit 0 | |
| fi | |
| echo "Killing nova-sim processes on port 3004: $PIDS" | |
| kill $PIDS | |