Add deployment scripts and documentation
- Add deployment scripts (deploy.sh, test_connection.sh, core/start_server.sh) - Add deployment documentation (DEPLOYMENT_INFO.md, DEPLOYMENT_SUCCESS.md) - Add .env.example configuration template - Add requirements.txt for Python dependencies - Update README.md with latest information - Update core/server.py with improvements 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
177
DEPLOYMENT_INFO.md
Normal file
177
DEPLOYMENT_INFO.md
Normal file
@@ -0,0 +1,177 @@
|
||||
# Funstat MCP 部署信息
|
||||
|
||||
## 服务器信息
|
||||
|
||||
- **服务器 IP**: 172.16.74.159
|
||||
- **用户**: atai
|
||||
- **部署路径**: /home/atai/funstat-mcp
|
||||
- **端口**: 8091 (本地监听)
|
||||
|
||||
## 部署状态
|
||||
|
||||
✅ **部署成功** - 2025-11-02
|
||||
|
||||
### 已安装组件
|
||||
|
||||
- Python 3.12.3
|
||||
- 虚拟环境: /home/atai/funstat-mcp/.venv
|
||||
- MCP 服务器: v1.20.0
|
||||
- Telethon: v1.41.2
|
||||
- 代理: v2ray (SOCKS5 on 127.0.0.1:1080)
|
||||
|
||||
### 配置文件
|
||||
|
||||
- **环境变量**: /home/atai/funstat-mcp/.env
|
||||
- **Session 文件**: ~/telegram_sessions/funstat_bot.session
|
||||
- **启动脚本**: /home/atai/funstat-mcp/core/start_server_with_env.sh
|
||||
|
||||
## 服务管理
|
||||
|
||||
### 启动服务
|
||||
|
||||
```bash
|
||||
ssh atai@172.16.74.159
|
||||
cd /home/atai/funstat-mcp/core
|
||||
bash start_server_with_env.sh
|
||||
```
|
||||
|
||||
### 停止服务
|
||||
|
||||
```bash
|
||||
ssh atai@172.16.74.159
|
||||
pkill -f 'funstat.*server.py'
|
||||
```
|
||||
|
||||
### 查看日志
|
||||
|
||||
```bash
|
||||
ssh atai@172.16.74.159
|
||||
tail -f /tmp/funstat_sse.log
|
||||
```
|
||||
|
||||
### 检查状态
|
||||
|
||||
```bash
|
||||
ssh atai@172.16.74.159
|
||||
ps aux | grep python | grep server.py
|
||||
netstat -tuln | grep 8091 # 或 ss -tuln | grep 8091
|
||||
```
|
||||
|
||||
## 服务端点
|
||||
|
||||
- **SSE 端点**: http://172.16.74.159:8091/sse
|
||||
- **消息端点**: http://172.16.74.159:8091/messages
|
||||
- **内部访问**: http://127.0.0.1:8091/sse
|
||||
|
||||
✅ 服务监听 0.0.0.0:8091,可从任何网络接口访问。
|
||||
|
||||
## 环境变量
|
||||
|
||||
当前配置在 `/home/atai/funstat-mcp/.env`:
|
||||
|
||||
```bash
|
||||
# Telegram API 配置
|
||||
TELEGRAM_API_ID=24660516
|
||||
TELEGRAM_API_HASH=eae564578880a59c9963916ff1bbbd3a
|
||||
TELEGRAM_SESSION_PATH=~/telegram_sessions/funstat_bot
|
||||
FUNSTAT_BOT_USERNAME=@openaiw_bot
|
||||
|
||||
# 代理配置
|
||||
FUNSTAT_PROXY_TYPE=socks5
|
||||
FUNSTAT_PROXY_HOST=127.0.0.1
|
||||
FUNSTAT_PROXY_PORT=1080
|
||||
|
||||
# 服务器配置
|
||||
FUNSTAT_HOST=0.0.0.0
|
||||
FUNSTAT_PORT=8091
|
||||
```
|
||||
|
||||
## 重新部署
|
||||
|
||||
从本地更新代码到服务器:
|
||||
|
||||
```bash
|
||||
cd /Users/hahaha/projects/funstat-mcp
|
||||
bash deploy.sh
|
||||
```
|
||||
|
||||
部署脚本会自动:
|
||||
1. 打包项目文件
|
||||
2. 上传到服务器
|
||||
3. 停止旧服务
|
||||
4. 解压更新文件
|
||||
5. 安装依赖
|
||||
|
||||
部署后需要手动启动服务:
|
||||
|
||||
```bash
|
||||
ssh atai@172.16.74.159
|
||||
cd /home/atai/funstat-mcp/core
|
||||
bash start_server_with_env.sh
|
||||
```
|
||||
|
||||
## 故障排除
|
||||
|
||||
### 1. 服务无法启动
|
||||
|
||||
检查日志:
|
||||
```bash
|
||||
tail -50 /tmp/funstat_sse.log
|
||||
```
|
||||
|
||||
### 2. 无法连接 Telegram
|
||||
|
||||
检查代理是否运行:
|
||||
```bash
|
||||
ps aux | grep v2ray
|
||||
netstat -tuln | grep 1080
|
||||
```
|
||||
|
||||
### 3. Session 文件锁定
|
||||
|
||||
强制停止并重启:
|
||||
```bash
|
||||
pkill -9 -f 'funstat.*server.py'
|
||||
sleep 2
|
||||
cd /home/atai/funstat-mcp/core
|
||||
bash start_server_with_env.sh
|
||||
```
|
||||
|
||||
## 运行日志示例
|
||||
|
||||
成功启动的日志应该包含:
|
||||
|
||||
```
|
||||
✅ 已连接到: KT超级数据
|
||||
✅ 当前账号: @xiaobai_80
|
||||
🚀 Funstat MCP Server 已启动
|
||||
🌐 启动 SSE 服务器: http://127.0.0.1:8091
|
||||
Uvicorn running on http://127.0.0.1:8091
|
||||
```
|
||||
|
||||
## 安全注意事项
|
||||
|
||||
1. ⚠️ .env 文件包含敏感信息,已设置权限保护
|
||||
2. ⚠️ Session 文件包含登录凭证,定期备份
|
||||
3. ⚠️ 服务监听 0.0.0.0:8091,可从任何网络访问,请注意安全
|
||||
4. ⚠️ 服务器需要使用 v2ray 代理访问 Telegram(端口 1080),确保代理服务稳定
|
||||
5. ⚠️ 必须使用 start_server_with_env.sh 启动脚本,才能正确加载环境变量和代理配置
|
||||
6. ⚠️ 建议在生产环境配置防火墙规则,限制访问来源IP
|
||||
|
||||
## 更新历史
|
||||
|
||||
- **2025-11-02**: 初次部署成功
|
||||
- 安装所有依赖(包括 PySocks)
|
||||
- 配置 v2ray 代理(socks5://127.0.0.1:1080)
|
||||
- 创建带环境变量的启动脚本
|
||||
- 配置服务监听 0.0.0.0:8091,支持外部访问
|
||||
- 服务正常运行
|
||||
- ⚠️ 注意:服务器无法直接访问 Telegram,必须使用代理
|
||||
- ✅ 可从任何网络通过 http://172.16.74.159:8091 访问
|
||||
|
||||
## 联系信息
|
||||
|
||||
- 服务器: 172.16.74.159:22
|
||||
- 账号: atai
|
||||
- Bot: @openaiw_bot
|
||||
- 当前 Telegram 账号: @xiaobai_80
|
||||
Reference in New Issue
Block a user