Files
gangyan/start_all.sh

59 lines
2.6 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.

#!/bin/bash
# 启动 gangyan 项目所有服务(与 /opt/start_all.sh 同步维护时可覆盖过去)
echo "启动 gangyan 项目服务..."
# 1. 启动 Docker 服务
echo "[1/4] 启动 Docker 服务..."
cd /opt/download/oss_files/gangyan-deploy/gangyan/milvus && docker compose up -d
cd /opt/download/oss_files/gangyan-deploy/gangyan/mysql/mysql-8.4.4 && docker compose up -d
docker start redis-server 2>/dev/null || docker run -d --name redis-server -p 6379:6379 redis:7-alpine
# 2. 启动 Java 后端MySQL 33306 / Redis 见 jar 内 application-yj.yml勿在此加 -Dspring.datasource* 以免覆盖端口)
echo "[2/4] 启动 Java 后端..."
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
pkill -f "chat_web_yj.jar" 2>/dev/null
sleep 2
cd /opt/download/oss_files/gangyan-deploy/gangyan/backend
LOCAL_CFG="/opt/download/oss_files/gangyan-deploy/gangyan/backend/application-local.yml"
EXTRA_JAVA=()
[ -f "$LOCAL_CFG" ] && EXTRA_JAVA=(-Dspring.config.additional-location="file:${LOCAL_CFG}")
nohup java -jar \
-Xms512m -Xmx2048m \
"${EXTRA_JAVA[@]}" \
-Dspring.profiles.active=yj \
chat_web_yj.jar > nohup.out 2>&1 &
# 3. 启动前端
echo "[3/4] 启动前端..."
if ! pgrep -f "vite" > /dev/null; then
cd /opt/download/oss_files/gangyan-deploy/gangyan/chat_web_front
nohup npm run dev > nohup.out 2>&1 &
fi
# 4. 启动 langchain-chat可选
# --all-api仅 API(7861)+依赖进程,不启 Streamlit WebUI-a 需要 pip install streamlit
echo "[4/4] 启动 langchain-chat可选..."
read -p "是否启动 langchain-chat? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
source /opt/software/miniconda3/etc/profile.d/conda.sh
conda activate langchain-chat
cd /opt/download/oss_files/gangyan-deploy/gangyan/langchain-chat
export PYTHONPATH="/opt/download/oss_files/gangyan-deploy/gangyan/langchain-chat"
nohup python startup.py --all-api > langchain.log 2>&1 &
echo "langchain-chat 启动中API :7861查看日志: tail -f langchain.log"
# PDF 预览依赖的本地转换微服务(:6006PyMuPDF 抽文本→Markdown
bash /opt/download/oss_files/gangyan-deploy/gangyan/scripts/pdf-convert-service.sh
echo "pdf-convert-service 已尝试启动(:6006日志: tail -f /opt/download/oss_files/gangyan-deploy/gangyan/logs/pdf-convert-service.log"
fi
echo ""
echo "服务启动完成!"
echo " 前端: http://localhost:3000/metalinfo"
echo " 后端: http://localhost:8099/chat_web_backend"
echo " MySQL: localhost:33306 (Docker 映射,勿用 3306 连宿主)"
echo " Redis: localhost:6379"
echo " Milvus: localhost:19530"