mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
chore: remove pm2 deployment docs and tooling
This commit is contained in:
@@ -9,7 +9,6 @@ NOFX documentation has been reorganized into a structured `docs/` directory for
|
||||
### Deployment Guides
|
||||
- `DOCKER_DEPLOY.en.md` → `docs/getting-started/docker-deploy.en.md`
|
||||
- `DOCKER_DEPLOY.md` → `docs/getting-started/docker-deploy.zh-CN.md`
|
||||
- `PM2_DEPLOYMENT.md` → `docs/getting-started/pm2-deploy.md`
|
||||
- `CUSTOM_API.md` → `docs/getting-started/custom-api.md`
|
||||
|
||||
### Community Docs
|
||||
@@ -42,7 +41,6 @@ nofx/
|
||||
├── README.uk.md
|
||||
├── DOCKER_DEPLOY.md
|
||||
├── DOCKER_DEPLOY.en.md
|
||||
├── PM2_DEPLOYMENT.md
|
||||
├── CUSTOM_API.md
|
||||
├── HOW_TO_POST_BOUNTY.md
|
||||
├── INTEGRATION_BOUNTY_HYPERLIQUID.md
|
||||
@@ -101,7 +99,6 @@ Files GitHub needs to see:
|
||||
|
||||
1. **`getting-started/`** - Deployment and setup
|
||||
- Docker deployment (EN/中文)
|
||||
- PM2 deployment
|
||||
- Custom API configuration
|
||||
|
||||
2. **`guides/`** - Usage guides and tutorials
|
||||
|
||||
@@ -17,15 +17,12 @@ Welcome to the NOFX documentation! This page helps you find the right documentat
|
||||
| [Getting Started Index (中文)](getting-started/README.zh-CN.md) | 所有部署选项 | All deployment options |
|
||||
| [Docker Deployment (EN)](getting-started/docker-deploy.en.md) | Deploy with Docker (recommended) | Docker 部署(推荐) |
|
||||
| [Docker Deployment (中文)](getting-started/docker-deploy.zh-CN.md) | Docker 部署指南(中文) | Docker deployment guide |
|
||||
| [PM2 Deployment (EN)](getting-started/pm2-deploy.en.md) | Deploy with PM2 process manager | PM2 进程管理器部署 |
|
||||
| [PM2 Deployment (中文)](getting-started/pm2-deploy.md) | PM2 部署指南(中文) | PM2 deployment guide |
|
||||
| [Custom API (EN)](getting-started/custom-api.en.md) | Connect custom AI API providers | 连接自定义 AI API |
|
||||
| [Custom API (中文)](getting-started/custom-api.md) | 连接自定义 AI API 提供商 | Custom AI provider guide |
|
||||
|
||||
**Quick Links:**
|
||||
- 📖 See all options → [Getting Started](getting-started/README.md) / [快速开始](getting-started/README.zh-CN.md)
|
||||
- 🐳 Want easiest setup? → [Docker (EN)](getting-started/docker-deploy.en.md) / [Docker (中文)](getting-started/docker-deploy.zh-CN.md)
|
||||
- 🔧 Advanced user? → [PM2 (EN)](getting-started/pm2-deploy.en.md) / [PM2 (中文)](getting-started/pm2-deploy.md)
|
||||
- 🤖 Custom AI model? → [Custom API (EN)](getting-started/custom-api.en.md) / [自定义 API](getting-started/custom-api.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -24,32 +24,11 @@ Choose the method that best fits your needs:
|
||||
**Quick Start:**
|
||||
```bash
|
||||
cp config.json.example config.json
|
||||
./start.sh start --build
|
||||
./scripts/start.sh start --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔧 PM2 Deployment
|
||||
|
||||
**Best for:** Advanced users, development, custom setups
|
||||
|
||||
- **English:** [pm2-deploy.en.md](pm2-deploy.en.md)
|
||||
- **中文:** [pm2-deploy.md](pm2-deploy.md)
|
||||
|
||||
**Pros:**
|
||||
- ✅ Direct process control
|
||||
- ✅ Better for development
|
||||
- ✅ Lower resource usage
|
||||
- ✅ More flexible
|
||||
|
||||
**Quick Start:**
|
||||
```bash
|
||||
go build -o nofx
|
||||
cd web && npm install && npm run build
|
||||
pm2 start ecosystem.config.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🤖 AI Configuration
|
||||
|
||||
@@ -77,7 +56,6 @@ Before starting, ensure you have:
|
||||
- ✅ Go 1.21+
|
||||
- ✅ Node.js 18+
|
||||
- ✅ TA-Lib library
|
||||
- ✅ PM2 (optional)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -22,32 +22,11 @@
|
||||
**快速开始:**
|
||||
```bash
|
||||
cp config.json.example config.json
|
||||
./start.sh start --build
|
||||
./scripts/start.sh start --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔧 PM2 部署
|
||||
|
||||
**适合:** 进阶用户、开发环境、自定义设置
|
||||
|
||||
- **中文文档:** [pm2-deploy.md](pm2-deploy.md)
|
||||
- **English:** [pm2-deploy.en.md](pm2-deploy.en.md)
|
||||
|
||||
**优势:**
|
||||
- ✅ 直接进程控制
|
||||
- ✅ 更适合开发
|
||||
- ✅ 资源占用更低
|
||||
- ✅ 更灵活
|
||||
|
||||
**快速开始:**
|
||||
```bash
|
||||
go build -o nofx
|
||||
cd web && npm install && npm run build
|
||||
pm2 start ecosystem.config.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🤖 AI 配置
|
||||
|
||||
@@ -75,7 +54,6 @@ pm2 start ecosystem.config.js
|
||||
- ✅ Go 1.21+
|
||||
- ✅ Node.js 18+
|
||||
- ✅ TA-Lib 库
|
||||
- ✅ PM2(可选)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
# NoFX Trading Bot - PM2 Deployment Guide
|
||||
|
||||
Complete guide for local development and production deployment using PM2.
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### 1. Install PM2
|
||||
|
||||
```bash
|
||||
npm install -g pm2
|
||||
```
|
||||
|
||||
### 2. One-Command Launch
|
||||
|
||||
```bash
|
||||
./pm2.sh start
|
||||
```
|
||||
|
||||
That's it! Frontend and backend will start automatically.
|
||||
|
||||
---
|
||||
|
||||
## 📋 All Commands
|
||||
|
||||
### Service Management
|
||||
|
||||
```bash
|
||||
# Start services
|
||||
./pm2.sh start
|
||||
|
||||
# Stop services
|
||||
./pm2.sh stop
|
||||
|
||||
# Restart services
|
||||
./pm2.sh restart
|
||||
|
||||
# View status
|
||||
./pm2.sh status
|
||||
|
||||
# Delete services
|
||||
./pm2.sh delete
|
||||
```
|
||||
|
||||
### Log Viewing
|
||||
|
||||
```bash
|
||||
# View all logs (live)
|
||||
./pm2.sh logs
|
||||
|
||||
# Backend logs only
|
||||
./pm2.sh logs backend
|
||||
|
||||
# Frontend logs only
|
||||
./pm2.sh logs frontend
|
||||
```
|
||||
|
||||
### Build & Compile
|
||||
|
||||
```bash
|
||||
# Compile backend
|
||||
./pm2.sh build
|
||||
|
||||
# Recompile backend and restart
|
||||
./pm2.sh rebuild
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
|
||||
```bash
|
||||
# Open PM2 monitoring dashboard (real-time CPU/Memory)
|
||||
./pm2.sh monitor
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Access URLs
|
||||
|
||||
After successful startup:
|
||||
|
||||
- **Frontend Web Interface**: http://localhost:3000
|
||||
- **Backend API**: http://localhost:8080
|
||||
- **Health Check**: http://localhost:8080/api/health
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuration Files
|
||||
|
||||
### pm2.config.js
|
||||
|
||||
PM2 configuration file, defines frontend and backend startup parameters:
|
||||
|
||||
```javascript
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'nofx-backend',
|
||||
script: './nofx', // Go binary
|
||||
cwd: __dirname, // Dynamically get current directory
|
||||
autorestart: true,
|
||||
max_memory_restart: '500M'
|
||||
},
|
||||
{
|
||||
name: 'nofx-frontend',
|
||||
script: 'npm',
|
||||
args: 'run dev', // Vite dev server
|
||||
cwd: path.join(__dirname, 'web'), // Dynamically join path
|
||||
autorestart: true,
|
||||
max_memory_restart: '300M'
|
||||
}
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
**After modifying configuration, restart is required:**
|
||||
```bash
|
||||
./pm2.sh restart
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 Log File Locations
|
||||
|
||||
- **Backend Logs**: `./logs/backend-error.log` and `./logs/backend-out.log`
|
||||
- **Frontend Logs**: `./web/logs/frontend-error.log` and `./web/logs/frontend-out.log`
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Startup on Boot
|
||||
|
||||
Set PM2 to start on boot:
|
||||
|
||||
```bash
|
||||
# 1. Start services
|
||||
./pm2.sh start
|
||||
|
||||
# 2. Save current process list
|
||||
pm2 save
|
||||
|
||||
# 3. Generate startup script
|
||||
pm2 startup
|
||||
|
||||
# 4. Follow the instructions to execute command (requires sudo)
|
||||
```
|
||||
|
||||
**Disable startup on boot:**
|
||||
```bash
|
||||
pm2 unstartup
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Common Operations
|
||||
|
||||
### Restart After Code Changes
|
||||
|
||||
**Backend changes:**
|
||||
```bash
|
||||
./pm2.sh rebuild # Auto compile and restart
|
||||
```
|
||||
|
||||
**Frontend changes:**
|
||||
```bash
|
||||
./pm2.sh restart # Vite will auto hot-reload, no restart needed
|
||||
```
|
||||
|
||||
### View Real-time Resource Usage
|
||||
|
||||
```bash
|
||||
./pm2.sh monitor
|
||||
```
|
||||
|
||||
### View Detailed Information
|
||||
|
||||
```bash
|
||||
pm2 info nofx-backend # Backend details
|
||||
pm2 info nofx-frontend # Frontend details
|
||||
```
|
||||
|
||||
### Clear Logs
|
||||
|
||||
```bash
|
||||
pm2 flush
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Service Startup Failed
|
||||
|
||||
```bash
|
||||
# 1. View detailed errors
|
||||
./pm2.sh logs
|
||||
|
||||
# 2. Check port usage
|
||||
lsof -i :8080 # Backend port
|
||||
lsof -i :3000 # Frontend port
|
||||
|
||||
# 3. Manual compile test
|
||||
go build -o nofx
|
||||
./nofx
|
||||
```
|
||||
|
||||
### Backend Won't Start
|
||||
|
||||
```bash
|
||||
# ~~Check if config.json exists~~
|
||||
# ~~ls -l config.json~~
|
||||
|
||||
# Check if database file exists
|
||||
ls -l trading.db
|
||||
|
||||
# Check permissions
|
||||
chmod +x nofx
|
||||
|
||||
# Run manually to see errors
|
||||
./nofx
|
||||
```
|
||||
|
||||
### Frontend Not Accessible
|
||||
|
||||
```bash
|
||||
# Check node_modules
|
||||
cd web && npm install
|
||||
|
||||
# Manual start test
|
||||
npm run dev
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Production Environment Recommendations
|
||||
|
||||
### 1. Use Production Mode
|
||||
|
||||
Modify `pm2.config.js`:
|
||||
|
||||
```javascript
|
||||
{
|
||||
name: 'nofx-frontend',
|
||||
script: 'npm',
|
||||
args: 'run preview', // Change to preview (requires npm run build first)
|
||||
env: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Increase Instances (Load Balancing)
|
||||
|
||||
```javascript
|
||||
{
|
||||
name: 'nofx-backend',
|
||||
script: './nofx',
|
||||
instances: 2, // Start 2 instances
|
||||
exec_mode: 'cluster'
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Auto Restart Strategy
|
||||
|
||||
```javascript
|
||||
{
|
||||
autorestart: true,
|
||||
max_restarts: 10,
|
||||
min_uptime: '10s',
|
||||
max_memory_restart: '500M'
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📦 Comparison with Docker Deployment
|
||||
|
||||
| Feature | PM2 Deployment | Docker Deployment |
|
||||
|---------|---------------|-------------------|
|
||||
| Startup Speed | ⚡ Fast | 🐌 Slower |
|
||||
| Resource Usage | 💚 Low | 🟡 Medium |
|
||||
| Isolation | 🟡 Medium | 💚 High |
|
||||
| Use Case | Dev/Single-machine | Production/Cluster |
|
||||
| Configuration Complexity | 💚 Simple | 🟡 Medium |
|
||||
|
||||
**Recommendations:**
|
||||
- **Development Environment**: Use `./pm2.sh`
|
||||
- **Production Environment**: Use `./start.sh` (Docker)
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Getting Help
|
||||
|
||||
```bash
|
||||
./pm2.sh help
|
||||
```
|
||||
|
||||
Or check PM2 official documentation: https://pm2.keymetrics.io/
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT
|
||||
@@ -1,303 +0,0 @@
|
||||
# NoFX Trading Bot - PM2 部署指南
|
||||
|
||||
使用 PM2 进行本地开发和生产部署的完整指南。
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 1. 安装 PM2
|
||||
|
||||
```bash
|
||||
npm install -g pm2
|
||||
```
|
||||
|
||||
### 2. 一键启动
|
||||
|
||||
```bash
|
||||
./pm2.sh start
|
||||
```
|
||||
|
||||
就这么简单!前后端将自动启动。
|
||||
|
||||
---
|
||||
|
||||
## 📋 所有命令
|
||||
|
||||
### 服务管理
|
||||
|
||||
```bash
|
||||
# 启动服务
|
||||
./pm2.sh start
|
||||
|
||||
# 停止服务
|
||||
./pm2.sh stop
|
||||
|
||||
# 重启服务
|
||||
./pm2.sh restart
|
||||
|
||||
# 查看状态
|
||||
./pm2.sh status
|
||||
|
||||
# 删除服务
|
||||
./pm2.sh delete
|
||||
```
|
||||
|
||||
### 日志查看
|
||||
|
||||
```bash
|
||||
# 查看所有日志(实时)
|
||||
./pm2.sh logs
|
||||
|
||||
# 只看后端日志
|
||||
./pm2.sh logs backend
|
||||
|
||||
# 只看前端日志
|
||||
./pm2.sh logs frontend
|
||||
```
|
||||
|
||||
### 构建与编译
|
||||
|
||||
```bash
|
||||
# 编译后端
|
||||
./pm2.sh build
|
||||
|
||||
# 重新编译后端并重启
|
||||
./pm2.sh rebuild
|
||||
```
|
||||
|
||||
### 监控
|
||||
|
||||
```bash
|
||||
# 打开 PM2 监控面板(实时CPU/内存)
|
||||
./pm2.sh monitor
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 访问地址
|
||||
|
||||
启动成功后:
|
||||
|
||||
- **前端 Web 界面**: http://localhost:3000
|
||||
- **后端 API**: http://localhost:8080
|
||||
- **健康检查**: http://localhost:8080/api/health
|
||||
|
||||
---
|
||||
|
||||
## 🔧 配置文件
|
||||
|
||||
### pm2.config.js
|
||||
|
||||
PM2 配置文件,定义了前后端的启动参数:
|
||||
|
||||
```javascript
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'nofx-backend',
|
||||
script: './nofx', // Go 二进制文件
|
||||
cwd: __dirname, // 动态获取当前目录
|
||||
autorestart: true,
|
||||
max_memory_restart: '500M'
|
||||
},
|
||||
{
|
||||
name: 'nofx-frontend',
|
||||
script: 'npm',
|
||||
args: 'run dev', // Vite 开发服务器
|
||||
cwd: path.join(__dirname, 'web'), // 动态拼接路径
|
||||
autorestart: true,
|
||||
max_memory_restart: '300M'
|
||||
}
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
**修改配置后需要重启:**
|
||||
```bash
|
||||
./pm2.sh restart
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 日志文件位置
|
||||
|
||||
- **后端日志**: `./logs/backend-error.log` 和 `./logs/backend-out.log`
|
||||
- **前端日志**: `./web/logs/frontend-error.log` 和 `./web/logs/frontend-out.log`
|
||||
|
||||
---
|
||||
|
||||
## 🔄 开机自启动
|
||||
|
||||
设置 PM2 开机自启动:
|
||||
|
||||
```bash
|
||||
# 1. 启动服务
|
||||
./pm2.sh start
|
||||
|
||||
# 2. 保存当前进程列表
|
||||
pm2 save
|
||||
|
||||
# 3. 生成启动脚本
|
||||
pm2 startup
|
||||
|
||||
# 4. 按照提示执行命令(需要 sudo)
|
||||
```
|
||||
|
||||
**取消开机自启动:**
|
||||
```bash
|
||||
pm2 unstartup
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ 常见操作
|
||||
|
||||
### 修改代码后重启
|
||||
|
||||
**后端修改:**
|
||||
```bash
|
||||
./pm2.sh rebuild # 自动编译并重启
|
||||
```
|
||||
|
||||
**前端修改:**
|
||||
```bash
|
||||
./pm2.sh restart # Vite 会自动热重载,无需重启
|
||||
```
|
||||
|
||||
### 查看实时资源占用
|
||||
|
||||
```bash
|
||||
./pm2.sh monitor
|
||||
```
|
||||
|
||||
### 查看详细信息
|
||||
|
||||
```bash
|
||||
pm2 info nofx-backend # 后端详情
|
||||
pm2 info nofx-frontend # 前端详情
|
||||
```
|
||||
|
||||
### 清空日志
|
||||
|
||||
```bash
|
||||
pm2 flush
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐛 故障排查
|
||||
|
||||
### 服务启动失败
|
||||
|
||||
```bash
|
||||
# 1. 查看详细错误
|
||||
./pm2.sh logs
|
||||
|
||||
# 2. 检查端口占用
|
||||
lsof -i :8080 # 后端端口
|
||||
lsof -i :3000 # 前端端口
|
||||
|
||||
# 3. 手动编译测试
|
||||
go build -o nofx
|
||||
./nofx
|
||||
```
|
||||
|
||||
### 后端无法启动
|
||||
|
||||
```bash
|
||||
# ~~检查 config.json 是否存在~~
|
||||
# ~~ls -l config.json~~
|
||||
|
||||
# 检查数据库文件是否存在
|
||||
ls -l trading.db
|
||||
|
||||
# 检查权限
|
||||
chmod +x nofx
|
||||
|
||||
# 手动运行看报错
|
||||
./nofx
|
||||
```
|
||||
|
||||
### 前端无法访问
|
||||
|
||||
```bash
|
||||
# 检查 node_modules
|
||||
cd web && npm install
|
||||
|
||||
# 手动启动测试
|
||||
npm run dev
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 生产环境建议
|
||||
|
||||
### 1. 使用生产模式
|
||||
|
||||
修改 `pm2.config.js`:
|
||||
|
||||
```javascript
|
||||
{
|
||||
name: 'nofx-frontend',
|
||||
script: 'npm',
|
||||
args: 'run preview', // 改为 preview(需先 npm run build)
|
||||
env: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 增加实例数(负载均衡)
|
||||
|
||||
```javascript
|
||||
{
|
||||
name: 'nofx-backend',
|
||||
script: './nofx',
|
||||
instances: 2, // 启动 2 个实例
|
||||
exec_mode: 'cluster'
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 自动重启策略
|
||||
|
||||
```javascript
|
||||
{
|
||||
autorestart: true,
|
||||
max_restarts: 10,
|
||||
min_uptime: '10s',
|
||||
max_memory_restart: '500M'
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📦 与 Docker 部署的对比
|
||||
|
||||
| 特性 | PM2 部署 | Docker 部署 |
|
||||
|------|---------|------------|
|
||||
| 启动速度 | ⚡ 快 | 🐌 较慢 |
|
||||
| 资源占用 | 💚 低 | 🟡 中等 |
|
||||
| 隔离性 | 🟡 中等 | 💚 高 |
|
||||
| 适用场景 | 开发/单机 | 生产/集群 |
|
||||
| 配置复杂度 | 💚 简单 | 🟡 中等 |
|
||||
|
||||
**建议:**
|
||||
- **开发环境**: 使用 `./pm2.sh`
|
||||
- **生产环境**: 使用 `./start.sh` (Docker)
|
||||
|
||||
---
|
||||
|
||||
## 🆘 获取帮助
|
||||
|
||||
```bash
|
||||
./pm2.sh help
|
||||
```
|
||||
|
||||
或查看 PM2 官方文档:https://pm2.keymetrics.io/
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT
|
||||
@@ -403,22 +403,24 @@ docker compose up -d
|
||||
#### ❌ Trader Configuration Not Saving
|
||||
|
||||
**Check:**
|
||||
1. **Permissions:**
|
||||
1. **PostgreSQL container health**
|
||||
```bash
|
||||
ls -l config.db trading.db
|
||||
# Should be writable by current user
|
||||
docker compose ps postgres
|
||||
docker compose exec postgres pg_isready -U nofx -d nofx
|
||||
```
|
||||
|
||||
2. **Disk Space:**
|
||||
2. **Inspect data directly**
|
||||
```bash
|
||||
./scripts/view_pg_data.sh # quick overview
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT COUNT(*) FROM traders;"
|
||||
```
|
||||
|
||||
3. **Disk space**
|
||||
```bash
|
||||
df -h # Ensure disk not full
|
||||
```
|
||||
|
||||
3. **Database Integrity:**
|
||||
```bash
|
||||
sqlite3 config.db "PRAGMA integrity_check;"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 How to Capture Logs
|
||||
@@ -437,15 +439,9 @@ docker compose logs -f backend
|
||||
docker compose logs backend --tail=500 > backend_logs.txt
|
||||
```
|
||||
|
||||
**Manual/PM2:**
|
||||
**Manual binary:**
|
||||
```bash
|
||||
# Terminal where you ran ./nofx shows logs
|
||||
|
||||
# PM2:
|
||||
pm2 logs nofx --lines 100
|
||||
|
||||
# Save to file
|
||||
pm2 logs nofx --lines 500 > backend_logs.txt
|
||||
# If running without Docker, the terminal running ./nofx prints logs
|
||||
```
|
||||
|
||||
---
|
||||
@@ -532,13 +528,16 @@ docker compose restart frontend
|
||||
|
||||
```bash
|
||||
# Check traders in database
|
||||
sqlite3 config.db "SELECT id, name, ai_model_id, exchange_id, is_running FROM traders;"
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT id, name, ai_model_id, exchange_id, is_running FROM traders;"
|
||||
|
||||
# Check AI models
|
||||
sqlite3 config.db "SELECT id, name, model_type, enabled FROM ai_models;"
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT id, name, provider, enabled FROM ai_models;"
|
||||
|
||||
# Check system config
|
||||
sqlite3 config.db "SELECT key, value FROM system_config;"
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT key, value FROM system_config;"
|
||||
```
|
||||
|
||||
---
|
||||
@@ -572,12 +571,12 @@ If you've tried all the above and still have problems:
|
||||
# Stop everything
|
||||
docker compose down
|
||||
|
||||
# Backup databases (just in case)
|
||||
cp config.db config.db.backup
|
||||
cp trading.db trading.db.backup
|
||||
# Optional: back up PostgreSQL data
|
||||
docker compose exec postgres \
|
||||
pg_dump -U nofx -d nofx > backup_nofx.sql
|
||||
|
||||
# Remove databases (fresh start)
|
||||
rm config.db trading.db
|
||||
# Remove all persisted volumes (fresh start)
|
||||
docker compose down -v
|
||||
|
||||
# Restart
|
||||
docker compose up -d --build
|
||||
|
||||
@@ -403,22 +403,24 @@ docker compose up -d
|
||||
#### ❌ 交易员配置无法保存
|
||||
|
||||
**检查:**
|
||||
1. **权限:**
|
||||
1. **PostgreSQL 容器状态**
|
||||
```bash
|
||||
ls -l config.db trading.db
|
||||
# 应该对当前用户可写
|
||||
docker compose ps postgres
|
||||
docker compose exec postgres pg_isready -U nofx -d nofx
|
||||
```
|
||||
|
||||
2. **磁盘空间:**
|
||||
2. **直接检查数据库数据**
|
||||
```bash
|
||||
./scripts/view_pg_data.sh # 快速总览
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT COUNT(*) FROM traders;"
|
||||
```
|
||||
|
||||
3. **磁盘空间**
|
||||
```bash
|
||||
df -h # 确保磁盘未满
|
||||
```
|
||||
|
||||
3. **数据库完整性:**
|
||||
```bash
|
||||
sqlite3 config.db "PRAGMA integrity_check;"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 如何捕获日志
|
||||
@@ -437,15 +439,9 @@ docker compose logs -f backend
|
||||
docker compose logs backend --tail=500 > backend_logs.txt
|
||||
```
|
||||
|
||||
**手动/PM2:**
|
||||
**手动运行:**
|
||||
```bash
|
||||
# 运行 ./nofx 的终端会显示日志
|
||||
|
||||
# PM2:
|
||||
pm2 logs nofx --lines 100
|
||||
|
||||
# 保存到文件
|
||||
pm2 logs nofx --lines 500 > backend_logs.txt
|
||||
# 如果不是通过 Docker,而是手动运行 ./nofx,可直接在终端查看日志
|
||||
```
|
||||
|
||||
---
|
||||
@@ -532,13 +528,16 @@ docker compose restart frontend
|
||||
|
||||
```bash
|
||||
# 检查数据库中的交易员
|
||||
sqlite3 config.db "SELECT id, name, ai_model_id, exchange_id, is_running FROM traders;"
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT id, name, ai_model_id, exchange_id, is_running FROM traders;"
|
||||
|
||||
# 检查 AI 模型
|
||||
sqlite3 config.db "SELECT id, name, model_type, enabled FROM ai_models;"
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT id, name, provider, enabled FROM ai_models;"
|
||||
|
||||
# 检查系统配置
|
||||
sqlite3 config.db "SELECT key, value FROM system_config;"
|
||||
docker compose exec postgres \
|
||||
psql -U nofx -d nofx -c "SELECT key, value FROM system_config;"
|
||||
```
|
||||
|
||||
---
|
||||
@@ -572,12 +571,12 @@ sqlite3 config.db "SELECT key, value FROM system_config;"
|
||||
# 停止所有服务
|
||||
docker compose down
|
||||
|
||||
# 备份数据库(以防万一)
|
||||
cp config.db config.db.backup
|
||||
cp trading.db trading.db.backup
|
||||
# 可选:备份 PostgreSQL 数据
|
||||
docker compose exec postgres \
|
||||
pg_dump -U nofx -d nofx > backup_nofx.sql
|
||||
|
||||
# 删除数据库(全新开始)
|
||||
rm config.db trading.db
|
||||
# 删除所有持久化卷(全新开始)
|
||||
docker compose down -v
|
||||
|
||||
# 重启
|
||||
docker compose up -d --build
|
||||
|
||||
Reference in New Issue
Block a user