fix: освобождать порт 3000 перед запуском shop.service

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 13:31:56 +03:00
parent f13ec7f29a
commit d31a63829c
6 changed files with 87 additions and 11 deletions
+31
View File
@@ -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} свободен"