#!/usr/bin/env bash # Script dừng dịch vụ web-giao-ban DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" cd "$DIR" if systemctl is-active web-giao-ban.service >/dev/null 2>&1; then echo "Stopping web-giao-ban via systemd..." sudo systemctl stop web-giao-ban echo "Stopped." else PID_FILE="$DIR/.app.pid" if [ -f "$PID_FILE" ]; then PID="$(cat "$PID_FILE")" if kill -0 "$PID" 2>/dev/null; then echo "Stopping web-giao-ban (PID: $PID)..." kill "$PID" 2>/dev/null || true sleep 1 fi rm -f "$PID_FILE" echo "Stopped." else # Kill by port 3000 if running PID=$(lsof -t -i:3000 2>/dev/null || fuser 3000/tcp 2>/dev/null) if [ -n "$PID" ]; then echo "Killing process on port 3000 (PID: $PID)..." kill -9 $PID 2>/dev/null || true echo "Stopped." else echo "web-giao-ban is not running." fi fi fi