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:
64
core/start_server.sh
Executable file
64
core/start_server.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
# Funstat MCP 服务器启动脚本(适配服务器环境)
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# 停止旧实例
|
||||
echo "🛑 停止旧服务器..."
|
||||
pkill -f "funstat.*server.py" 2>/dev/null || true
|
||||
sleep 2
|
||||
|
||||
# 确保 session 文件没有被锁定
|
||||
SESSION_FILE=~/telegram_sessions/funstat_bot.session
|
||||
if [ -f "$SESSION_FILE" ]; then
|
||||
if lsof "$SESSION_FILE" 2>/dev/null; then
|
||||
echo "⚠️ Session 文件被占用,强制终止..."
|
||||
pkill -9 -f "funstat.*server.py" || true
|
||||
sleep 2
|
||||
fi
|
||||
else
|
||||
echo "❌ Session 文件不存在: $SESSION_FILE"
|
||||
echo "请先上传 session 文件!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 激活虚拟环境
|
||||
source ../.venv/bin/activate
|
||||
|
||||
# 启动新服务器(后台运行)
|
||||
echo "🚀 启动新服务器..."
|
||||
nohup python3 server.py > /tmp/funstat_sse.log 2>&1 &
|
||||
SERVER_PID=$!
|
||||
|
||||
# 等待启动
|
||||
sleep 3
|
||||
|
||||
# 验证启动
|
||||
if ps -p $SERVER_PID > /dev/null 2>&1; then
|
||||
echo "✅ 服务器已启动 (PID: $SERVER_PID)"
|
||||
echo "📡 SSE 端点: http://127.0.0.1:8091/sse"
|
||||
echo "📋 日志文件: /tmp/funstat_sse.log"
|
||||
|
||||
# 测试端点
|
||||
echo ""
|
||||
echo "🧪 测试端点..."
|
||||
if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8091/sse | grep -q "200"; then
|
||||
echo "✅ GET /sse 测试通过"
|
||||
else
|
||||
echo "❌ GET /sse 测试失败"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📊 服务器状态:"
|
||||
echo " 进程ID: $SERVER_PID"
|
||||
echo " 监听地址: http://127.0.0.1:8091"
|
||||
echo " 日志: tail -f /tmp/funstat_sse.log"
|
||||
echo ""
|
||||
echo "停止服务: pkill -f 'funstat.*server.py'"
|
||||
else
|
||||
echo "❌ 服务器启动失败!"
|
||||
echo "查看日志: tail -50 /tmp/funstat_sse.log"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user