52 lines
1.1 KiB
Bash
52 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
echo "启动装备成本估算系统..."
|
|
|
|
# 检查配置文件
|
|
if [ ! -f config/.env ]; then
|
|
echo "错误: 配置文件不存在"
|
|
echo "请先运行 install.sh"
|
|
exit 1
|
|
fi
|
|
|
|
# 检查日志目录
|
|
if [ ! -d logs ]; then
|
|
mkdir -p logs
|
|
fi
|
|
|
|
# 激活虚拟环境
|
|
source venv/bin/activate
|
|
|
|
# 导出环境变量
|
|
export $(cat config/.env | xargs)
|
|
|
|
# 启动后端服务
|
|
echo "启动后端服务..."
|
|
gunicorn -w 4 -b 0.0.0.0:5001 "src.app:create_app()" \
|
|
--daemon \
|
|
--pid gunicorn.pid \
|
|
--access-logfile logs/access.log \
|
|
--error-logfile logs/error.log
|
|
|
|
# 等待后端服务启动
|
|
sleep 2
|
|
|
|
# 检查后端服务是否成功启动
|
|
if ! curl -s http://localhost:5001/api/ > /dev/null; then
|
|
echo "错误: 后端服务启动失败"
|
|
exit 1
|
|
fi
|
|
|
|
# 启动前端服务
|
|
echo "启动前端服务..."
|
|
cd frontend
|
|
npm run serve -- --port 8080 --host 0.0.0.0 &
|
|
echo $! > ../frontend.pid
|
|
cd ..
|
|
|
|
echo "服务已启动!"
|
|
echo "后端API: http://localhost:5001"
|
|
echo "前端界面: http://localhost:8080"
|
|
echo "查看后端日志: tail -f logs/access.log"
|
|
echo "查看前端日志: tail -f logs/frontend.log"
|