Files
crypto_monitor/deploy/README.md
T
dekun 4923b32bbe feat: 新增 Plan B 整目录重装脚本,不影响 setup_env 一键安装
添加 deploy/reinstall.sh 备份 env、克隆、调 setup_env、恢复配置并 PM2 启动;
附带 pm2_start_all.sh 与 hub_settings 清理工具。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 22:07:59 +08:00

83 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 环境一键部署(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 # 仅部分子项目
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
```
**整目录重装**(保留 `.env`、清库、去脏 PM2)见 **[reinstall-plan-b.md](./reinstall-plan-b.md)**,执行 `bash deploy/reinstall.sh`。与 `setup_env.sh` 独立,不影响首次一键安装。
若在其它环境编辑过脚本后报 `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
```
或一条命令:`bash deploy/pm2_start_all.sh`
3. 三所 `.env` 同步脚本见 **[docs/env-sync-scripts.md](../docs/env-sync-scripts.md)**。
---
## 依赖说明
- 三个监控子项目共用根目录 **[requirements.txt](../requirements.txt)**。
- 走 SOCKS 须 **PySocks**(已包含在 requirements 中)。