1282293e91
Add docs/ubuntu-server.md; remove Windows and alternate process managers from deployment guides; index strategy, key monitor, TP/SL, breakeven, and replay docs in root README. Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
2.2 KiB
Markdown
79 lines
2.2 KiB
Markdown
# 环境一键部署(Ubuntu / root /opt)
|
||
|
||
在 **`/opt/crypto_monitor`** 下以 **root** 为各子项目创建 Python **`.venv`**、安装依赖、从 `.env.example` 生成 `.env`(不覆盖已有),并可选安装 **PM2**。
|
||
|
||
完整系统要求(Python / Node / PM2 版本、启动顺序)见 **[docs/ubuntu-server.md](../docs/ubuntu-server.md)**。
|
||
|
||
---
|
||
|
||
## 前置条件
|
||
|
||
- **Ubuntu 22.04 / 24.04**,用户 **root**
|
||
- 已安装 **git**,仓库位于 **`/opt/crypto_monitor`**
|
||
|
||
```bash
|
||
apt update
|
||
apt install -y python3 python3-pip python3-venv curl git ca-certificates
|
||
# Node 20 + PM2 见 docs/ubuntu-server.md §3
|
||
```
|
||
|
||
---
|
||
|
||
## 一键执行
|
||
|
||
```bash
|
||
cd /opt/crypto_monitor
|
||
bash deploy/setup_env.sh --install-system-deps
|
||
```
|
||
|
||
常用参数:
|
||
|
||
```bash
|
||
bash deploy/setup_env.sh --only binance,gate_bot # 仅部分子项目
|
||
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
|
||
```
|
||
|
||
若在其它环境编辑过脚本后报 `pipefail` 错误,先转 LF:
|
||
|
||
```bash
|
||
sed -i 's/\r$//' deploy/setup_env.sh
|
||
```
|
||
|
||
---
|
||
|
||
## 脚本会做什么
|
||
|
||
| 步骤 | 说明 |
|
||
|------|------|
|
||
| 检查 Python | 需要 **3.10+** |
|
||
| `crypto_monitor_*` | 各目录 `.venv` + `pip install -r ../requirements.txt` |
|
||
| `manual_trading_hub` | 独立 `requirements.txt` |
|
||
| `.env` | 不存在则从 `.env.example` 复制 |
|
||
| 目录 | `static/images`、`static/images/order_charts` |
|
||
| PM2 | 已装 Node 时 `npm install -g pm2` |
|
||
|
||
---
|
||
|
||
## 部署之后
|
||
|
||
1. 编辑各子目录 **`.env`**(API、登录密码、SOCKS、AI 复盘等)。
|
||
2. **仅用 PM2 常驻**(见 [docs/ubuntu-server.md](../docs/ubuntu-server.md) §3):
|
||
|
||
```bash
|
||
cd /opt/crypto_monitor/crypto_monitor_binance && pm2 start ecosystem.config.cjs
|
||
# … 其余三所 …
|
||
cd /opt/crypto_monitor/manual_trading_hub && pm2 start ecosystem.config.cjs
|
||
pm2 save
|
||
```
|
||
|
||
3. 四所 `.env` 同步脚本见 **[docs/env-sync-scripts.md](../docs/env-sync-scripts.md)**。
|
||
|
||
---
|
||
|
||
## 依赖说明
|
||
|
||
- 四个监控子项目共用根目录 **[requirements.txt](../requirements.txt)**。
|
||
- 走 SOCKS 须 **PySocks**(已包含在 requirements 中)。
|