deploy: 一键部署内置 locale/时区/SimNow 前置探测与 CTP 验证

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 11:59:02 +08:00
parent b4250171d5
commit ca894dfd4d
3 changed files with 149 additions and 19 deletions
+17 -6
View File
@@ -46,14 +46,20 @@ bash deploy.sh
`deploy.sh` 会自动完成:
1. 安装 `python3``python3-venv``git``nodejs``npm``pm2`
2. `git pull``git clone``/opt/qihuo`
3. 创建虚拟环境 `venv``pip install -r requirements.txt`
4. 首次生成 `.env`(随机 `SECRET_KEY`
5. `pm2 start ecosystem.config.cjs``pm2 save`
1. 安装系统依赖:`python3``git``build-essential``python3-dev``pkg-config``locales``netcat-openbsd``pm2`
2. **时区**设为 `Asia/Shanghai`(与 SimNow 交易时段一致)
3. **locale**:生成 `zh_CN.GB18030``zh_CN.UTF-8`CTP 登录必需,缺则进程崩溃)
4. `git pull``git clone``/opt/qihuo`
5. 创建/保留虚拟环境 `venv``pip install -r requirements.txt`,验证 `vnpy_ctp`
6. 首次生成 `.env`,并补全 `SIMNOW_ENV=实盘``CTP_AUTO_RECONNECT=true` 等缺项
7. **自动探测 SimNow 前置**`nc` 测端口),写入可用的 `SIMNOW_TD/MD_ADDRESS`(优先 `182.254.243.31`,其次 `180.168.146.187`
8. 若已配置 SimNow 账号,运行 `scripts/test_simnow.py` 验证连接
9. `pm2 restart --update-env` 或首次 `pm2 start`,并 `pm2 save`
部署完成后访问:`http://<服务器IP>:6600`
> 再次部署只需 `cd /opt/qihuo && bash deploy.sh`,无需手工装 locale 或改前置地址。
---
## 手动部署
@@ -62,7 +68,12 @@ bash deploy.sh
```bash
apt update
apt install -y python3 python3-venv python3-pip python3-dev pkg-config git nodejs npm build-essential
apt install -y python3 python3-venv python3-pip python3-dev pkg-config git nodejs npm build-essential locales netcat-openbsd
timedatectl set-timezone Asia/Shanghai
sed -i '/^# zh_CN.GB18030/s/^# //' /etc/locale.gen
sed -i '/^# zh_CN.UTF-8/s/^# //' /etc/locale.gen
locale-gen zh_CN.GB18030 zh_CN.UTF-8
update-locale LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8
npm install -g pm2
```