Files
diary-system/deploy_multiuser.sh

57 lines
1.4 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
# 多用户系统 - 部署脚本
set -e
echo "======================================"
echo "🚀 部署多用户日记系统"
echo "======================================"
cd /home/ubuntu/diary-system
# 1. 安装依赖
echo "📦 安装 Python 依赖..."
cd backend
pip3 install -r requirements.txt -q 2>/dev/null || pip3 install -r requirements.txt --break-system-packages -q
# 2. 数据库迁移
echo "🗄️ 执行数据库迁移..."
python3 manage.py migrate --run-syncdb
# 3. 迁移现有数据到默认用户
echo "📦 迁移现有数据..."
python3 ../migrate_data.py
# 4. 重启 Gunicorn
echo "⚙️ 重启 Gunicorn..."
sudo systemctl restart diary-system
# 5. 检查服务状态
echo ""
echo "🔍 检查服务状态..."
sudo systemctl is-active diary-system > /dev/null && echo " ✅ Gunicorn 运行中" || echo " ❌ Gunicorn 未运行"
# 6. 测试访问
echo ""
echo "🧪 测试访问..."
sleep 2
if curl -s http://127.0.0.1:8002/api/auth/me/ > /dev/null 2>&1; then
echo " ✅ 认证 API 正常"
else
echo " ⚠️ 认证 API 可能有问题"
fi
echo ""
echo "======================================"
echo "✅ 部署完成!"
echo "======================================"
echo ""
echo "📍 访问地址http://cssc.datalibstar.com:8001/"
echo ""
echo "📝 默认用户:"
echo " 用户名beijixing"
echo " 密码beijixing123"
echo ""
echo "💡 其他用户可以注册新账号使用"
echo ""