3.2 KiB
3.2 KiB
CMPP 平台生产部署手册
本次生产端口
- 运营端、客户端页面:
http://8.160.169.106:12026 - API:仅本机
127.0.0.1:3000,由 Nginx/api/反向代理。 - Redis:仅本机
127.0.0.1:6379。 - PostgreSQL:仅本机
127.0.0.1:5432。 - MinIO:仅本机
127.0.0.1:9000/9001,页面上传下载通过 API 转发。 - Gateway 控制服务:仅本机
127.0.0.1:8090。 - CMPP 入站端口:
17890已作为部署变量保留;当前 Go Gateway 代码尚未实现完整入站 CMPP Server,不要把 HTTP 控制服务误当作 CMPP 监听。
首次部署
- 本机提交并推送
main。 - 使用 root 登录服务器,或先放置免密 SSH key。
- 在服务器执行:
curl -fsSL http://175.27.255.91:3000/hectorzhao/lislgosms/raw/branch/main/tools/deploy/production-bootstrap.sh -o /root/production-bootstrap.sh
bash /root/production-bootstrap.sh
可覆盖的环境变量:
APP_DIR=/opt/cmpp-platform
REPO_URL=http://175.27.255.91:3000/hectorzhao/lislgosms.git
BRANCH=main
PUBLIC_HTTP_PORT=12026
API_PORT=3000
GATEWAY_CMPP_ADDR=0.0.0.0:17890
OBJECT_STORAGE_DRIVER=minio
OBJECT_STORAGE_LOCAL_ROOT=/var/lib/cmpp-platform/object-storage
PROD_ADMIN_EMAIL=admin@example.com
PROD_ADMIN_USERNAME=prod_admin
PROD_ADMIN_PASSWORD='change-me'
脚本会安装 Node.js、Go、PostgreSQL、Redis、MinIO、Nginx,创建 systemd 服务,执行 Prisma migrate,构建前端/API/Gateway,并创建平台管理员。Node.js、Go 和 MinIO 下载会按服务器架构自动选择 x64/amd64 或 arm64。
如生产验证服务器临时无法稳定下载 MinIO,可显式传入 OBJECT_STORAGE_DRIVER=local,文件会通过真实 API 保存到服务器本地目录 OBJECT_STORAGE_LOCAL_ROOT,cmpp-minio 服务会跳过安装和启动。该模式只建议用于验证环境;正式生产建议恢复 OBJECT_STORAGE_DRIVER=minio。
后续发布
cd /opt/cmpp-platform
git fetch origin main
git reset --hard origin/main
bash tools/deploy/production-deploy.sh
账号和密钥
- 生产管理员账号写入
/root/cmpp-platform-admin.txt。 - 首次部署汇总凭据写入
/root/cmpp-platform-credentials.txt。 - 这两个文件权限为
600,不要提交到 Git。 - root 密码后续可修改;SSH 私钥放入
/root/.ssh/authorized_keys后即可免密登录。
日志
journalctl -u cmpp-api -f
journalctl -u cmpp-gateway -f
journalctl -u cmpp-minio -f
tail -f /opt/cmpp-platform/logs/api/stderr.log
tail -f /opt/cmpp-platform/logs/gateway/stderr.log
健康检查
curl http://127.0.0.1:3000/api/health
curl http://127.0.0.1:8090/health
curl http://127.0.0.1:12026/
redis-cli -h 127.0.0.1 -p 6379 ping
pg_isready -d "$(grep '^DATABASE_URL=' /etc/cmpp-platform/cmpp-platform.env | cut -d= -f2-)"
回滚
- 数据库备份:
pg_dump "$(grep '^DATABASE_URL=' /etc/cmpp-platform/cmpp-platform.env | cut -d= -f2-)" > /opt/cmpp-platform/backups/cmpp-$(date +%F-%H%M%S).sql
- 回滚代码:
cd /opt/cmpp-platform
git reset --hard <上一版提交>
bash tools/deploy/production-deploy.sh
- 如迁移造成不可兼容故障,先停服务,再恢复数据库备份。