feat: add CodiMD database port-forward helper scripts

Add three scripts to simplify CodiMD database access via port-forward:
- db-port-forward.sh: Start SSH tunnel and kubectl port-forward
- db-port-forward-stop.sh: Stop port-forward processes
- db-status.sh: Check port-forward status

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 12:06:47 +08:00
parent a0e20877a2
commit 67d41fa688
3 changed files with 105 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# 停止 CodiMD 資料庫 Port Forward
echo "=== 停止 CodiMD 資料庫 Port Forward ==="
# 方法 1: 使用保存的 PID
if [ -f /tmp/codimd-db-port-forward.pid ]; then
PID=$(cat /tmp/codimd-db-port-forward.pid)
if ps -p $PID > /dev/null 2>&1; then
kill $PID
echo "✅ 已終止 PID: $PID"
rm -f /tmp/codimd-db-port-forward.pid
exit 0
else
echo "⚠️ PID $PID 不存在,嘗試其他方法..."
rm -f /tmp/codimd-db-port-forward.pid
fi
fi
# 方法 2: 使用 pgrep
PIDS=$(pgrep -f "port-forward.*codimd-db")
if [ -n "$PIDS" ]; then
echo "找到運行中的 port-forward process(es):"
echo "$PIDS"
pkill -f "port-forward.*codimd-db"
echo "✅ 已終止所有相關 process"
exit 0
fi
echo "❌ 沒有找到運行中的 port-forward"
exit 1