update start.sh
This commit is contained in:
parent
8739964ef7
commit
647eb3797b
10
app.py
10
app.py
|
|
@ -24,14 +24,14 @@ def hello(name: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def run_spider_in_vnc(index: int) -> str:
|
async def start_vnc_server(index: int) -> str:
|
||||||
"""在 VNC 会话中运行爬虫
|
"""启动VNC服务
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
index: VNC 显示编号
|
index: VNC 显示编号
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 调用外部 start.sh 脚本,传入 index 作为参数
|
# 调用外部 start_vnc.sh 脚本,传入 index 作为参数
|
||||||
process = await asyncio.create_subprocess_exec(
|
process = await asyncio.create_subprocess_exec(
|
||||||
"/home/dgs/vnc-server/start_vnc.sh",
|
"/home/dgs/vnc-server/start_vnc.sh",
|
||||||
str(index),
|
str(index),
|
||||||
|
|
@ -40,9 +40,9 @@ async def run_spider_in_vnc(index: int) -> str:
|
||||||
)
|
)
|
||||||
stdout, stderr = await process.communicate()
|
stdout, stderr = await process.communicate()
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
return f"✅ 爬虫执行成功\n输出:\n{stdout.decode()}"
|
return f"✅ VNC服务启动成功\n输出:\n{stdout.decode()}"
|
||||||
else:
|
else:
|
||||||
return f"❌ 爬虫执行失败\n错误:\n{stderr.decode()}"
|
return f"❌ VNC服务启动失败\n错误:\n{stderr.decode()}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"❌ 执行出错: {str(e)}"
|
return f"❌ 执行出错: {str(e)}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,31 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#wget -O- -q --show-progress https://git.nps.crabapples.cn/crabapples/learn-spider/raw/branch/main/bin/auto_install.sh | bash
|
#wget -O- -q --show-progress https://git.nps.crabapples.cn/crabapples/learn-spider/raw/branch/main/bin/auto_install.sh | bash
|
||||||
|
# wget -q --show-progress https://git.nps.crabapples.cn/crabapples/learn-spider/raw/branch/main/bin/close_vnc.sh && chmod +x close_vnc.sh
|
||||||
|
|
||||||
GIT_DOMAIN=https://git.nps.crabapples.cn
|
GIT_DOMAIN=https://git.nps.crabapples.cn
|
||||||
echo "清理旧脚本..."
|
echo "清理旧脚本..."
|
||||||
rm -rf ./install.sh ./start.sh ./update.sh ./uninstall.sh
|
|
||||||
|
rm -rf ./install.sh ./start_vnc.sh ./close_vnc.sh ./start_spider.sh ./update.sh ./uninstall.sh
|
||||||
echo "开始下载..."
|
echo "开始下载..."
|
||||||
|
|
||||||
echo "下载安装脚本..."
|
echo "下载安装脚本..."
|
||||||
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/install.sh && chmod +x install.sh
|
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/install.sh && chmod +x install.sh
|
||||||
echo "下载启动脚本..."
|
|
||||||
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/start.sh && chmod +x start.sh
|
echo "下载启动VNC脚本..."
|
||||||
|
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/start_vnc.sh && chmod +x start_vnc.sh
|
||||||
|
|
||||||
|
echo "下载关闭VNC脚本..."
|
||||||
|
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/close_vnc.sh && chmod +x close_vnc.sh
|
||||||
|
|
||||||
|
echo "下载启动爬虫脚本..."
|
||||||
|
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/start_spider.sh && chmod +x start_spider.sh
|
||||||
|
|
||||||
echo "下载更新脚本..."
|
echo "下载更新脚本..."
|
||||||
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/update.sh && chmod +x update.sh
|
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/update.sh && chmod +x update.sh
|
||||||
|
|
||||||
echo "下载卸载脚本..."
|
echo "下载卸载脚本..."
|
||||||
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/uninstall.sh && chmod +x uninstall.sh
|
wget -q --show-progress $GIT_DOMAIN/crabapples/learn-spider/raw/branch/main/bin/uninstall.sh && chmod +x uninstall.sh
|
||||||
|
|
||||||
echo "下载完成"
|
echo "下载完成"
|
||||||
echo "开始安装..."
|
echo "开始安装..."
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue