update start.sh

This commit is contained in:
mshe 2026-06-08 16:28:02 +08:00
parent 6d8e52f484
commit 59c9da1623
2 changed files with 13 additions and 9 deletions

18
app.py
View File

@ -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
)

View File

@ -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