Files
crypto_monitor/deploy/README.md
T
dekun 823aeda42a Add hub AI config tab with sync to instances and deploy secret bootstrap.
Wire bootstrap_deploy_secrets into setup_env.sh (one-time HUB_BRIDGE_TOKEN, FLASK_SECRET_KEY, HUB_SESSION_SECRET). Remove AI section from instance env UI; hub saves OPENAI settings to all four .env files. SSO unchanged.

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

84 lines
2.6 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` 复制 |
| 部署密钥 | `python3 scripts/bootstrap_deploy_secrets.py`(不覆盖已有值) |
| 目录 | `static/images``static/images/order_charts` |
| PM2 | 已装 Node 时 `npm install -g pm2` |
---
## 部署之后
1. 编辑各子目录 **`.env`**(交易所 API、企业微信等;**AI 请在中控系统设置 → 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 中)。