Add Ubuntu interactive one-click deploy; default sim mode.

Ship deploy/manage.sh toolkit for /opt/coinox, rewrite Ubuntu-only deploy docs, drop Windows deploy guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 08:35:07 +08:00
parent 88b7fb7a0a
commit 4a4de8f5fb
13 changed files with 1884 additions and 692 deletions
+101
View File
@@ -0,0 +1,101 @@
# CoinOX 环境一键部署(Ubuntu / root /opt)
在 **`/opt/coinox`** 下以 **root** 部署CoinOX 币本位期权 + U 本位对冲,使用 **PM2** 常驻.
仓库: [https://git.bz121.com/dekun/CoinOX.git](https://git.bz121.com/dekun/CoinOX.git)
完整步骤见根目录 **[部署文档.md](../部署文档.md)**.
---
## 一键部署管理器(推荐)
新服务器**无需先 clone**,一条命令进入菜单:
```bash
curl -fsSL https://git.bz121.com/dekun/CoinOX/raw/branch/main/deploy/manage.sh | bash
```
已安装机器:
```bash
bash /opt/coinox/deploy/manage.sh
```
### 菜单
| 选项 | 功能 |
|------|------|
| **1) 一键部署** | 环境识别 + 系统依赖 + Node/PM2 + venv + 密钥 + 启动 `coinox` |
| **2) 一键卸载** | 备份 `.env` → 停 PM2 → 移走目录 |
| **3) 更新** | 快速更新 / 依赖更新 |
| **4) 仅检测** | 识别 OS / Python / Node / PM2 / 项目状态(不安装) |
| **0) 退出** | |
### 部署完成后
- 访问: `http://<服务器IP>:5010` (端口以 `.env` 的 `APP_PORT` 为准)
- 默认入口: `/hedge-plan`(对冲)/ `/options`(期权);默认模拟盘 sim
- 登录账号: **admin**(密码见 `.env` 的 `APP_PASSWORD`,首次脚本可写成 `admin123`)
---
## 脚本结构
```
deploy/
├── manage.sh # 入口(自举 + 菜单)
├── lib/
│ ├── common.sh # 公共函数 / 环境识别 / 验收
│ ├── install.sh # 一键部署
│ ├── uninstall.sh # 一键卸载
│ ├── update.sh # 更新子菜单
│ └── doctor.sh # 仅检测
├── setup_env.sh # venv + pip(被 install 调用)
└── pull_and_restart.sh # 快速更新
```
---
## 前置条件
- **Ubuntu 22.04 / 24.04**,用户 **root**
- 能 `git clone` [coinox](https://git.bz121.com/dekun/CoinOX.git) 到 `/opt/coinox`
---
## 分步安装(仍可用)
```bash
cd /opt
git clone https://git.bz121.com/dekun/CoinOX.git coinox
cd /opt/coinox
bash deploy/setup_env.sh --install-system-deps
pm2 start ecosystem.config.cjs
pm2 save && pm2 startup
```
`setup_env.sh` 常用参数:
```bash
bash deploy/setup_env.sh --recreate-venv # 重建虚拟环境
bash deploy/setup_env.sh --skip-pm2 # 不尝试安装 pm2
bash deploy/setup_env.sh --skip-env-copy # 不复制 .env.example
```
若在 Windows 编辑过脚本后报 `pipefail` 错误,先转 LF:
```bash
sed -i 's/\r$//' deploy/manage.sh deploy/lib/*.sh deploy/*.sh
```
---
## 环境变量(可选)
```bash
INSTALL_ROOT=/opt/coinox
GIT_URL=https://git.bz121.com/dekun/CoinOX.git
GIT_BRANCH=main
BACKUP_ROOT=/root/backups
```