Update
This commit is contained in:
1 parent
2105a0c5f7
commit
c89d4825e2
30 files changed
+5435
-627
No files matched your search
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -f ".env_dev" ]]; then
|
||||
set -a
|
||||
source .env_dev
|
||||
set +a
|
||||
fi
|
||||
|
||||
APP_PORT="${APP_PORT:-3911}"
|
||||
BACKEND_PORT="${BACKEND_PORT:-3002}"
|
||||
API_PROXY_TARGET="${API_PROXY_TARGET:-http://127.0.0.1:${BACKEND_PORT}}"
|
||||
export APP_PORT BACKEND_PORT API_PROXY_TARGET
|
||||
export NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
kill_port_processes() {
|
||||
local port="$1"
|
||||
local pids=""
|
||||
|
||||
if command -v lsof >/dev/null 2>&1; then
|
||||
pids="${pids}"$'\n'"$(lsof -tiTCP:"${port}" -sTCP:LISTEN 2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
if command -v fuser >/dev/null 2>&1; then
|
||||
pids="${pids}"$'\n'"$(fuser -n tcp "${port}" 2>/dev/null | tr ' ' '\n' || true)"
|
||||
fi
|
||||
|
||||
if command -v ss >/dev/null 2>&1; then
|
||||
pids="${pids}"$'\n'"$(ss -ltnp "sport = :${port}" 2>/dev/null | grep -o 'pid=[0-9]*' | cut -d= -f2 || true)"
|
||||
fi
|
||||
|
||||
pids="$(printf '%s\n' "${pids}" | sed '/^$/d' | sort -u)"
|
||||
|
||||
if [[ -z "${pids}" ]]; then
|
||||
echo "Port ${port} ist frei."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Beende Prozess(e) auf Port ${port}: ${pids//$'\n'/ }"
|
||||
kill ${pids} 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
local remaining=""
|
||||
for pid in ${pids}; do
|
||||
if kill -0 "${pid}" 2>/dev/null; then
|
||||
remaining="${remaining} ${pid}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "${remaining}" ]]; then
|
||||
echo "Erzwinge Stop für:${remaining}"
|
||||
kill -9 ${remaining} 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
kill_port_processes "${BACKEND_PORT}"
|
||||
if [[ "${APP_PORT}" != "${BACKEND_PORT}" ]]; then
|
||||
kill_port_processes "${APP_PORT}"
|
||||
fi
|
||||
Reference in new issue
Block a user