neural-sync/stop.sh

45 lines
1.2 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.

#!/bin/bash
# Neural Sync 停止器 - 停止所有服务
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$PROJECT_DIR"
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "🛑 停止 Neural Sync 服务"
echo "===================="
# 从 PID 文件读取并停止
if [ -f "logs/backend.pid" ]; then
BACKEND_PID=$(cat logs/backend.pid)
if ps -p $BACKEND_PID > /dev/null 2>&1; then
kill $BACKEND_PID 2>/dev/null
echo -e "${GREEN}✅ 后端已停止 (PID: $BACKEND_PID)${NC}"
fi
rm logs/backend.pid
fi
if [ -f "logs/frontend.pid" ]; then
FRONTEND_PID=$(cat logs/frontend.pid)
if ps -p $FRONTEND_PID > /dev/null 2>&1; then
kill $FRONTEND_PID 2>/dev/null
echo -e "${GREEN}✅ 前端已停止 (PID: $FRONTEND_PID)${NC}"
fi
rm logs/frontend.pid
fi
# 清理端口
lsof -ti:8000 2>/dev/null | xargs kill -9 2>/dev/null || true
lsof -ti:5173 2>/dev/null | xargs kill -9 2>/dev/null || true
# 停止 Ollama(可选)
read -p "是否同时停止 Ollama? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
pkill -9 -f "ollama serve" 2>/dev/null && echo -e "${GREEN}✅ Ollama 已停止${NC}" || true
fi
echo -e "${GREEN}🎉 所有服务已停止${NC}"