release: bump version to 1.1.7, update xq0031_xq0032 plugin to 1.0.8
主要变更: 1. 整体版本升级至1.1.7,更新安装包与shell版本号 2. 新增API与后端能力: - 新增停止运行接口,支持强制终止插件进程与浏览器子进程 - 云端会话令牌与下载票据落库,适配多worker部署 - 优化Chrome版本读取逻辑,避免弹窗与编码问题 3. xq0031_xq0032插件升级至1.0.8: - 新增仓库中文名自动筛选功能,简化用户操作 - 优化ERP登录与报表导出流程,修复标签页残留问题 - 新增前端强制停止按钮,支持实时终止运行 - 修复中文编码与乱码问题,兼容Windows非UTF-8环境 4. 修复授权校验逻辑,确保账号与授权匹配 5. 更新文档与部署脚本,修正发版流程说明
This commit is contained in:
@@ -32,6 +32,34 @@ class RunReq(BaseModel):
|
||||
fields: dict = {}
|
||||
|
||||
|
||||
# ==================== 手动强制停止 ====================
|
||||
# run_id → 执行中 Job 句柄(供 POST /api/runs/{id}/stop 整树强杀,含浏览器孙进程)
|
||||
_ACTIVE: dict = {}
|
||||
_ACTIVE_LOCK = threading.Lock()
|
||||
_USER_STOPPED: set = set()
|
||||
_STOP_LOCK = threading.Lock()
|
||||
|
||||
|
||||
def terminate_run(run_id: str) -> bool:
|
||||
"""手动终止运行:登记停止标记并整树强杀 Job。返回是否已找到并触发终止。"""
|
||||
with _ACTIVE_LOCK:
|
||||
job = _ACTIVE.get(run_id)
|
||||
with _STOP_LOCK:
|
||||
_USER_STOPPED.add(run_id)
|
||||
if job is None:
|
||||
return False # 尚未真正拉起执行子进程(排队中)或已结束
|
||||
try:
|
||||
job.terminate()
|
||||
except Exception:
|
||||
pass
|
||||
return True
|
||||
|
||||
|
||||
def _is_user_stopped(run_id: str) -> bool:
|
||||
with _STOP_LOCK:
|
||||
return run_id in _USER_STOPPED
|
||||
|
||||
|
||||
def _run_target(plugin, fields: dict, run_id: str) -> None:
|
||||
"""进程级隔离执行插件:拉起独立 python 子进程,stdout JSON 事件转发 /ws,超时强杀。
|
||||
|
||||
@@ -55,14 +83,24 @@ def _run_target(plugin, fields: dict, run_id: str) -> None:
|
||||
|
||||
# Windows Job Object:整树托管(含浏览器孙进程),超时整树强杀 + 内存上限兜底
|
||||
job = _winjob.Job(max_mem_mb=max_mem_mb)
|
||||
# 子进程 stdio 编码统一 UTF-8:默认跟随 Windows locale(GBK) 会导致
|
||||
# stderr 中文 traceback 变 mojibake、stdin JSON 中文解出孤立代理字符
|
||||
_child_env = dict(os.environ)
|
||||
_child_env["PYTHONIOENCODING"] = "utf-8"
|
||||
_child_env["PYTHONUTF8"] = "1"
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
cmd,
|
||||
cwd=str(root), stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, text=True, encoding="utf-8",
|
||||
errors="replace",
|
||||
errors="replace", env=_child_env,
|
||||
# 抑制宿主进程的控制台窗口(runner.exe 为 console 子系统),
|
||||
# 同时 stdout/stderr 走 PIPE 捕获不受影响
|
||||
creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0),
|
||||
)
|
||||
job.assign(proc)
|
||||
with _ACTIVE_LOCK:
|
||||
_ACTIVE[run_id] = job # 登记句柄,供手动强制停止整树强杀
|
||||
except Exception as e: # noqa: BLE001 子进程拉起失败
|
||||
job.close()
|
||||
_st._set_run(run_id, status="error", result=None, error=f"拉起执行子进程失败: {e}")
|
||||
@@ -134,6 +172,10 @@ def _run_target(plugin, fields: dict, run_id: str) -> None:
|
||||
result=ev.get("result"), error=ev.get("error"))
|
||||
HUB.publish({"t": "run_done", "run_id": run_id, "ok": ok,
|
||||
"error": ev.get("error")})
|
||||
elif _is_user_stopped(run_id):
|
||||
msg = "用户手动强制停止"
|
||||
_st._set_run(run_id, status="error", result=None, error=msg)
|
||||
HUB.publish({"t": "run_done", "run_id": run_id, "ok": False, "error": msg})
|
||||
elif timed_out:
|
||||
msg = f"插件执行超时({timeout}s)已强制终止"
|
||||
_st._set_run(run_id, status="error", result=None, error=msg)
|
||||
@@ -143,6 +185,8 @@ def _run_target(plugin, fields: dict, run_id: str) -> None:
|
||||
_st._set_run(run_id, status="error", result=None, error=msg)
|
||||
HUB.publish({"t": "run_done", "run_id": run_id, "ok": False, "error": msg})
|
||||
finally:
|
||||
with _ACTIVE_LOCK:
|
||||
_ACTIVE.pop(run_id, None)
|
||||
_scheduler.mark_done(plugin.id, run_id) # 单活槽位回空闲并唤醒排队请求
|
||||
_report_run(plugin.id, run_id) # 运行上报(联网实时/离线暂存补报)
|
||||
job.close() # KILL_ON_JOB_CLOSE 兜底清理残留子进程
|
||||
|
||||
Reference in New Issue
Block a user