diff --git a/start_dashboard.py b/start_dashboard.py index aba4aab..0248b55 100644 --- a/start_dashboard.py +++ b/start_dashboard.py @@ -43,6 +43,23 @@ def start_websocket_server(): except Exception as e: print(f"WebSocket服务器启动失败: {e}") +def start_feishu_longconn_service(): + """启动飞书长连接服务""" + try: + import logging + logger = logging.getLogger("feishu_longconn") + logger.info("=" * 80) + logger.info("🚀 启动飞书长连接服务(后台线程)") + logger.info("=" * 80) + + from src.integrations.feishu_longconn_service import get_feishu_longconn_service + service = get_feishu_longconn_service() + service.start() # 这会阻塞当前线程 + except Exception as e: + print(f"❌ 飞书长连接服务启动失败: {e}") + import traceback + traceback.print_exc() + def check_database_connection(): """检查数据库连接""" try: @@ -100,6 +117,8 @@ def main(): print(f" 实时对话: http://localhost:{config.server.port}/chat") print(f" WebSocket: ws://localhost:{config.server.websocket_port}") print() + print("🤖 飞书长连接服务: 已在后台启动") + print() print("按 Ctrl+C 停止服务") print("=" * 60) @@ -107,6 +126,14 @@ def main(): websocket_thread = threading.Thread(target=start_websocket_server, daemon=True) websocket_thread.start() + # 在单独线程中启动飞书长连接服务 + feishu_thread = threading.Thread(target=start_feishu_longconn_service, daemon=True) + feishu_thread.start() + + # 等待飞书服务初始化 + import time + time.sleep(2) + # 启动Flask应用 app.run( debug=config.server.debug,