修正env

This commit is contained in:
dekun
2026-05-16 23:39:37 +08:00
parent a86d1a44dd
commit eb32ec70b5
22 changed files with 250 additions and 40 deletions
+21 -3
View File
@@ -44,6 +44,7 @@ mkdir -p /opt/crypto_monitor/crypto_monitor_okx
cd /opt/crypto_monitor
tar -xzf crypto_monitor.tgz -C crypto_monitor_okx
cd crypto_monitor_okx
cp -n .env.example .env # 若尚无 .env
```
---
@@ -127,14 +128,31 @@ export PYTHONDONTWRITEBYTECODE=1
---
## 5. 配置 `.env`(本机
## 5. 配置环境变量(`.env.example` → `.env`
复制示例环境文件(仓库里通常有 `.env`;没有就自己创建):
| 文件 | 是否进 Git | 说明 |
|------|------------|------|
| **`.env.example`** | ✅ 是 | 变量模板与注释,可随 `git pull` 更新 |
| **`.env`** | ❌ 否 | 本机真实配置;`app.py` **只读此文件** |
### 5.1 首次配置
```bash
cp .env .env.local # 可选:备份
cd /opt/crypto_monitor/crypto_monitor_okx
cp -n .env.example .env # 已存在 .env 时不覆盖
nano .env
```
### 5.2 备份与 `git pull`
- **`.env` 不在 Git 中**`git pull` **不会**覆盖本地 `.env`
- 远端若更新 **`.env.example`**,pull 后请**手动**把新增变量补进你的 `.env`
- **升级前备份**`cp .env .env.backup.$(date +%Y%m%d)`;恢复:`cp .env.backup.YYYYMMDD .env`
- **换机**`scp` 复制 `.env`,或新机 `cp .env.example .env` 后重填。
### 5.3 必填项检查(OKX + 代理)
至少确认/填写这些关键项(示例):
```env