Files
dsh_shenxian/scripts/teardown-rehearsal.sh
T
admin 5ec99ce227
build / build-and-scan (push) Canceled after 0s
chore: 文档库全量重新入库(2026-10-20)
2026-10-20 15:05:55 +08:00

32 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 拆除演练环境(为生产切换让路):
# · 47:演练 Manager(127.0.0.1:13080)
# · 106:两个演练 agent(19000/19001)⇒ 会 teardown 实例并关闭隧道
# 目的:① 释放 47 的 15432(隧道转发占用 → 生产 PG 要用)
# ② 避免"演练 Manager + 生产 Manager 抢同一个 agent"
set -uo pipefail
echo "=== 47 侧:停演练 Manager(按端口定位,绝不碰生产 3080) ==="
PID=$(ss -lntpH 'sport = :13080' 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1)
if [ -n "$PID" ]; then kill "$PID" && echo " 已停演练 Manager pid=$PID"; else echo " 13080 无监听"; fi
sleep 2
echo "=== 106 侧:停两个演练 agent ==="
for port in 19000 19001; do
pid=$(ss -lntpH "sport = :$port" 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1)
[ -n "$pid" ] && kill "$pid" && echo " 已停 agent($port) pid=$pid" || echo " $port 无监听"
done
sleep 4
echo " 残留 dsh 实例: $(pgrep -cf 'dsh --profile' || echo 0)"
echo " 隧道进程: $(pgrep -cf 'tunnel_ed25519' || echo 0)"
echo "=== 47 侧:15432 是否已释放(隧道转发应已消失) ==="
ss -lntp 2>/dev/null | grep 15432 || echo " ✓ 15432 已空闲"
echo "=== 加固:若隧道 sshd 残留,按端口收掉 ==="
for port in 19000 19001 15432; do
pid=$(ss -lntpH "sport = :$port" 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1)
[ -n "$pid" ] && kill "$pid" 2>/dev/null && echo " 收掉残留监听 $port pid=$pid"
done
sleep 2
ss -lntp 2>/dev/null | grep -E "15432|1900[01]" || echo " ✓ 三个端口都已空闲"