93 lines
2.8 KiB
Markdown
93 lines
2.8 KiB
Markdown
# 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 监听。
|
|
|
|
## 首次部署
|
|
|
|
1. 本机提交并推送 `main`。
|
|
2. 使用 root 登录服务器,或先放置免密 SSH key。
|
|
3. 在服务器执行:
|
|
|
|
```bash
|
|
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
|
|
```
|
|
|
|
可覆盖的环境变量:
|
|
|
|
```bash
|
|
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
|
|
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,并创建平台管理员。Go 和 MinIO 下载会按服务器架构自动选择 `linux-amd64` 或 `linux-arm64`。
|
|
|
|
## 后续发布
|
|
|
|
```bash
|
|
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` 后即可免密登录。
|
|
|
|
## 日志
|
|
|
|
```bash
|
|
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
|
|
```
|
|
|
|
## 健康检查
|
|
|
|
```bash
|
|
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-)"
|
|
```
|
|
|
|
## 回滚
|
|
|
|
1. 数据库备份:
|
|
|
|
```bash
|
|
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
|
|
```
|
|
|
|
2. 回滚代码:
|
|
|
|
```bash
|
|
cd /opt/cmpp-platform
|
|
git reset --hard <上一版提交>
|
|
bash tools/deploy/production-deploy.sh
|
|
```
|
|
|
|
3. 如迁移造成不可兼容故障,先停服务,再恢复数据库备份。
|