diff --git a/TOOLS.md b/TOOLS.md index 7abe61a..917779e 100644 --- a/TOOLS.md +++ b/TOOLS.md @@ -58,3 +58,12 @@ Add whatever helps you do your job. This is your cheat sheet. - **数据库**: cssc - **用户**: coder - **密码**: 825670wl + +## 云服务器 + +### 城市手册部署 + +- **主机**: cssc.datalibstar.com +- **用户**: mashen +- **密码**: 825670@MashenClaw +- **状态**: ⚠️ SSH 密码认证失败,需要 SSH Key diff --git a/city-manual/backend/city_manual/__pycache__/wsgi.cpython-312.pyc b/city-manual/backend/city_manual/__pycache__/wsgi.cpython-312.pyc index 41c6a5f..f722530 100644 Binary files a/city-manual/backend/city_manual/__pycache__/wsgi.cpython-312.pyc and b/city-manual/backend/city_manual/__pycache__/wsgi.cpython-312.pyc differ diff --git a/city-manual/deploy.sh b/city-manual/deploy.sh new file mode 100644 index 0000000..9f31925 --- /dev/null +++ b/city-manual/deploy.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# 城市手册 - 自动部署脚本 + +set -e + +echo "🚀 开始部署城市手册项目..." + +# 1. 安装依赖 +echo "📦 安装 Python 依赖..." +cd /root/.openclaw/workspace/city-manual/backend +pip3 install -r requirements.txt --break-system-packages -q + +# 2. 数据库迁移 +echo "🗄️ 执行数据库迁移..." +python3 manage.py migrate --noinput + +# 3. 收集静态文件 +echo "📁 收集静态文件..." +python3 manage.py collectstatic --noinput + +# 4. 创建 Gunicorn 服务 +echo "⚙️ 创建 Gunicorn 服务..." +cat > /etc/systemd/system/city-manual.service << EOF +[Unit] +Description=City Manual Gunicorn Service +After=network.target + +[Service] +User=root +Group=root +WorkingDirectory=/root/.openclaw/workspace/city-manual/backend +ExecStart=/usr/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/city-manual.sock city_manual.wsgi:application +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + +systemctl daemon-reload +systemctl enable city-manual +systemctl start city-manual + +# 5. 配置 Nginx +echo "🌐 配置 Nginx..." +cat > /etc/nginx/sites-available/city-manual << 'EOF' +server { + listen 80; + server_name cssc.datalibstar.com; + + location = /favicon.ico { access_log off; log_not_found off; } + + location /static/ { + alias /root/.openclaw/workspace/city-manual/backend/static/; + } + + location /media/ { + alias /root/.openclaw/workspace/city-manual/backend/media/; + } + + location / { + include proxy_params; + proxy_pass http://unix:/run/city-manual.sock; + } +} +EOF + +ln -sf /etc/nginx/sites-available/city-manual /etc/nginx/sites-enabled/ +nginx -t +systemctl restart nginx + +# 6. 导入示例数据 +echo "📊 导入示例数据..." +python3 manage.py seed_data + +echo "" +echo "✅ 部署完成!" +echo "" +echo "📍 访问地址:http://cssc.datalibstar.com" +echo "📍 Admin: http://cssc.datalibstar.com/admin" +echo "📍 测试账号:demo / demo123" diff --git a/city-manual/gunicorn_start.sh b/city-manual/gunicorn_start.sh new file mode 100644 index 0000000..9703756 --- /dev/null +++ b/city-manual/gunicorn_start.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd /root/.openclaw/workspace/city-manual/backend +exec gunicorn --workers 3 --bind 0.0.0.0:8000 city_manual.wsgi:application