fischer-agentkit/scripts/dev-stop.sh

41 lines
1.6 KiB
Bash
Executable File
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
# =============================================================================
# Fischer AgentKit — 本地开发环境一键停止脚本
# =============================================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"
echo "停止 Fischer AgentKit 开发服务..."
# 当前规范端口(与 agentkit.yaml / vite.config.ts 保持一致)
# 18001 — AgentKit 后端 API
# 18002 — Web GUI 内置静态服务
# 15173 — Vite 开发服务器Tauri 模式)
# 15174 — Vite HMR websocket
# 遗留端口一并清理,避免历史残留造成冲突
DEV_PORTS=(18001 18002 15173 15174 8000 8001 8002 5173 5175)
# 停止后端/API/GUI 进程(按端口)
for port in "${DEV_PORTS[@]}"; do
PID=$(lsof -ti :$port 2>/dev/null || true)
if [[ -n "$PID" ]]; then
kill -9 $PID 2>/dev/null && echo " [OK] 端口 $port 已停止 (PID $PID)" || true
fi
done
# 停止 Vite / esbuild 进程(按命令名匹配,避免误杀其他 node 服务)
pkill -f "vite --port 15173" 2>/dev/null && echo " [OK] Vite(:15173) 已停止" || true
pkill -f "vite --port 5175" 2>/dev/null && echo " [OK] Vite(:5175) 已停止" || true
pkill -f "esbuild.*ping" 2>/dev/null && echo " [OK] esbuild 服务进程已停止" || true
# 停止 Docker 容器(开发专用)
for container in fischer-redis-dev fischer-pg-dev; do
if docker ps --format '{{.Names}}' 2>/dev/null | grep -q "^${container}$"; then
docker stop "$container" 2>/dev/null && echo " [OK] 容器 $container 已停止" || true
fi
done
echo "停止完成。"