mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 16:30:29 +08:00
fbd30a7b4e
Former-commit-id: 6ffcf5714ef663afa22f891bdb566950e4c47b60
57 lines
1.4 KiB
Bash
Executable File
57 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# stop-all.sh — 停止所有 V2 测试环境服务 (PID 文件 + 进程名匹配)
|
|
source "$(dirname "${BASH_SOURCE[0]}")/config/env.sh"
|
|
|
|
log_info "Stopping all services..."
|
|
|
|
# 1. Stop by PID files
|
|
for pid_file in "$LOG_DIR"/*.pid; do
|
|
if [[ -f "$pid_file" ]]; then
|
|
pid=$(cat "$pid_file")
|
|
svc=$(basename "$pid_file" .pid)
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
log_info "Stopping $svc (pid=$pid)..."
|
|
kill "$pid" 2>/dev/null || true
|
|
sleep 2
|
|
kill -9 "$pid" 2>/dev/null || true
|
|
log_ok " $svc stopped"
|
|
else
|
|
log_info " $svc already dead (pid=$pid)"
|
|
fi
|
|
rm -f "$pid_file"
|
|
fi
|
|
done
|
|
|
|
# 2. Kill any remaining Java processes by name pattern
|
|
KILL_PATTERNS=(
|
|
"cw-elevator-application"
|
|
"ninca-crk-std-backend"
|
|
"ninca-qk-alarm-app"
|
|
"ninca-common"
|
|
"component-organization"
|
|
"cwos-portal"
|
|
"cwos-manager"
|
|
"cwos-system-api"
|
|
)
|
|
|
|
for pattern in "${KILL_PATTERNS[@]}"; do
|
|
pids=$(pgrep -f "$pattern" 2>/dev/null || true)
|
|
if [[ -n "$pids" ]]; then
|
|
for pid in $pids; do
|
|
log_info "Killing $pattern (pid=$pid)..."
|
|
kill "$pid" 2>/dev/null || true
|
|
sleep 1
|
|
kill -9 "$pid" 2>/dev/null || true
|
|
done
|
|
log_ok " $pattern cleaned up"
|
|
fi
|
|
done
|
|
|
|
# 3. Stop Docker containers
|
|
log_info "Stopping Docker containers..."
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
docker compose -f docker-compose.infra.yml down 2>/dev/null || true
|
|
log_ok " Docker containers stopped"
|
|
|
|
log_info "All services stopped"
|