fix: освобождать порт 3000 перед запуском shop.service
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Освободить порт 3000 (ручной npm start / старый процесс)
|
||||
set -euo pipefail
|
||||
|
||||
PORT="${1:-3000}"
|
||||
|
||||
if ! command -v ss >/dev/null; then
|
||||
echo "ss не найден"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! ss -tlnp | grep -q ":${PORT} "; then
|
||||
echo "Порт ${PORT} свободен"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Порт ${PORT} занят:"
|
||||
ss -tlnp | grep ":${PORT} " || true
|
||||
|
||||
if command -v fuser >/dev/null; then
|
||||
echo "Останавливаем процессы на ${PORT}/tcp..."
|
||||
fuser -k "${PORT}/tcp" 2>/dev/null || true
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
if ss -tlnp | grep -q ":${PORT} "; then
|
||||
echo "Порт ${PORT} всё ещё занят — остановите процесс вручную"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Порт ${PORT} свободен"
|
||||
Reference in New Issue
Block a user