first commit

This commit is contained in:
2026-05-21 16:44:31 +08:00
commit 7dbc5542de
99 changed files with 47743 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
# 环境一键部署
为仓库内各子项目创建 Python 虚拟环境、安装依赖、初始化 `.env` 与静态目录。
## Windows(推荐)
双击仓库根目录 **`一键部署.bat`**,或在 PowerShell 中:
```powershell
cd C:\path\to\crypto_monitor
.\deploy\setup_env.ps1
```
仅部署部分项目:
```powershell
.\deploy\setup_env.ps1 -Only binance,gate_bot
```
重建虚拟环境:
```powershell
.\deploy\setup_env.ps1 -RecreateVenv
```
跳过 PM2、跳过复制 `.env`
```powershell
.\deploy\setup_env.ps1 -SkipPm2 -SkipEnvCopy
```
## Linux / macOS
**Ubuntu / Debian 首次部署**(若 `python -m venv``ensurepip is not available`):
```bash
apt update
apt install -y python3.10-venv python3-pip curl # 版本号与 python3 --version 一致
bash deploy/setup_env.sh
```
脚本在 **root** 下会自动尝试 `apt install python*-venv`;非 root 请先装系统包或使用:
```bash
sudo bash deploy/setup_env.sh --install-system-deps
```
```bash
cd /opt/crypto_monitor
bash deploy/setup_env.sh
bash deploy/setup_env.sh --only binance,gate
bash deploy/setup_env.sh --recreate-venv
```
若在 Windows 编辑过脚本后在 Linux 报错 `set: pipefail: invalid option name`,先去掉 CRLF 再执行:
```bash
sed -i 's/\r$//' deploy/setup_env.sh
# 或: apt install -y dos2unix && dos2unix deploy/setup_env.sh
bash 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.js 且未 `-SkipPm2`,尝试 `npm install -g pm2` |
## 部署之后
1. 编辑各子目录 **`.env`**(API、登录密码、SOCKS 代理等)。
2. 本地试运行(以 Binance 为例):
```bash
cd crypto_monitor_binance
source .venv/bin/activate # Windows: .\.venv\Scripts\activate
python app.py
```
3. 服务器长期运行见各目录 **《部署文档.md》**SSH SOCKS、PM2)。
## 依赖说明
- 四个监控子项目共用仓库根目录 **[requirements.txt](../requirements.txt)**。
- 走 SOCKS 代理时必须安装 **PySocks**(已包含在 requirements 中)。