备份:修复前完整项目快照 2026-04-19
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "=== 开始完整部署 ==="
|
||||
|
||||
# 1. 停止所有node进程
|
||||
echo "1. 停止现有进程..."
|
||||
pkill -f 'node app' 2>/dev/null || true
|
||||
sleep 2
|
||||
|
||||
# 2. 删除旧数据库,让后端重新创建
|
||||
echo "2. 删除旧数据库..."
|
||||
rm -f /opt/company-finance-system/backend/data/finance.db
|
||||
rm -f /opt/company-finance-system/backend/finance.db
|
||||
find /opt/company-finance-system -name '*.db' -delete 2>/dev/null || true
|
||||
echo " 数据库已删除"
|
||||
|
||||
# 3. 安装后端依赖
|
||||
echo "3. 安装后端依赖..."
|
||||
cd /opt/company-finance-system/backend
|
||||
npm install --production 2>&1 | tail -3
|
||||
|
||||
# 4. 启动后端(会自动创建全新数据库)
|
||||
echo "4. 启动后端..."
|
||||
cd /opt/company-finance-system/backend
|
||||
PORT=3000 nohup node app.js > /var/log/backend.log 2>&1 &
|
||||
disown
|
||||
sleep 5
|
||||
|
||||
# 5. 检查后端是否启动
|
||||
echo "5. 检查后端状态..."
|
||||
if netstat -tlnp 2>/dev/null | grep 3000; then
|
||||
echo " 后端启动成功!"
|
||||
else
|
||||
echo " 后端启动失败,查看日志:"
|
||||
tail -20 /var/log/backend.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 6. 测试关键API
|
||||
echo "6. 测试关键API..."
|
||||
echo " - 健康检查: $(curl -s http://localhost:3000/api/health | head -c 50)"
|
||||
echo " - 登录测试: $(curl -s -X POST http://localhost:3000/api/auth/login -H 'Content-Type: application/json' -d '{"username":"admin","password":"X123c321@"}' | head -c 100)"
|
||||
echo " - 物流公司: $(curl -s http://localhost:3000/api/logistics-companies | head -c 100)"
|
||||
echo " - 采购订单: $(curl -s http://localhost:3000/api/purchase-orders | head -c 100)"
|
||||
echo " - 付款计划: $(curl -s http://localhost:3000/api/payment-plans | head -c 100)"
|
||||
echo " - 汇率: $(curl -s http://localhost:3000/api/exchange-rates | head -c 100)"
|
||||
echo " - 预算: $(curl -s http://localhost:3000/api/budget-projects | head -c 100)"
|
||||
echo " - 执行: $(curl -s http://localhost:3000/api/executions | head -c 100)"
|
||||
echo " - 客户: $(curl -s http://localhost:3000/api/customers | head -c 100)"
|
||||
echo " - 付款节点: $(curl -s http://localhost:3000/api/payment-nodes | head -c 100)"
|
||||
echo " - 付款记录: $(curl -s http://localhost:3000/api/payment-records | head -c 100)"
|
||||
|
||||
echo ""
|
||||
echo "=== 部署完成 ==="
|
||||
Reference in New Issue
Block a user