From 59c9da162382b251a5cd385936a5042a33218520 Mon Sep 17 00:00:00 2001 From: mshe <666666666@666666666.666666666> Date: Mon, 8 Jun 2026 16:28:02 +0800 Subject: [PATCH] update start.sh --- app.py | 18 ++++++++++-------- bin/start_spider.sh | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 7132877..60a21f3 100755 --- a/app.py +++ b/app.py @@ -15,17 +15,17 @@ def mail_qq_spider(account: str) -> str: """qq邮箱爬虫,第一个参数是用户名""" return a1(account) @mcp.tool() -async def start_vnc_server(index: int) -> str: +async def start_vnc_server(display: int) -> str: """启动VNC服务 Args: - index: VNC 显示编号 + display: VNC 显示编号 """ try: # 调用外部 start_vnc_server.sh 脚本,传入 index 作为参数 process = await asyncio.create_subprocess_exec( "/home/dgs/vnc-server/start_vnc_server.sh", - str(index), + str(display), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) @@ -38,17 +38,19 @@ async def start_vnc_server(index: int) -> str: return f"❌ 执行出错: {str(e)}" @mcp.tool() -async def start_spider(spider_code: str) -> str: +async def start_spider(spider_code: str,display: str) -> str: """启动爬虫 Args: spider_code: 爬虫代码 + display: 显示桌面编号 """ try: # 调用外部 start_spider.sh 脚本,传入 spider_code 作为参数 process = await asyncio.create_subprocess_exec( "/home/dgs/vnc-server/start_spider.sh", spider_code, + display, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) @@ -61,16 +63,16 @@ async def start_spider(spider_code: str) -> str: return f"❌ 执行出错: {str(e)}" @mcp.tool() -async def close_vnc_server(index: int) -> str: +async def close_vnc_server(display: int) -> str: """关闭 VNC 服务 Args: - index: VNC 显示编号 + display: VNC 显示编号 """ try: - # 调用外部 stop_vnc_server.sh 脚本,传入 index 作为参数 + # 调用外部 stop_vnc_server.sh 脚本,传入 display 作为参数 process = await asyncio.create_subprocess_exec( "/home/dgs/vnc-server/stop_vnc_server.sh", - str(index), + str(display), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) diff --git a/bin/start_spider.sh b/bin/start_spider.sh index 7b42f46..96178d7 100644 --- a/bin/start_spider.sh +++ b/bin/start_spider.sh @@ -1,7 +1,9 @@ #!/bin/bash spider_code=$1 +index=$2 PUBLIC_DIR="${2:-/shared}" - +export DISPLAY=:$index +echo "当前显示桌面:$DISPLAY" start_spider(){ echo "正在启动爬虫$spider_code" if [ "$spider_code" = "01" ]; then