From b658fc50d22d9b958de927d47c4ef46e997ad533 Mon Sep 17 00:00:00 2001 From: Suwings Date: Sun, 10 Jul 2022 13:55:11 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20=E6=96=B0=E5=A2=9E=E4=BC=98=E9=9B=85?= =?UTF-8?q?=E9=99=8D=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entity/commands/pty/pty_start.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/entity/commands/pty/pty_start.ts b/src/entity/commands/pty/pty_start.ts index 3ec0f70..1cc93a6 100644 --- a/src/entity/commands/pty/pty_start.ts +++ b/src/entity/commands/pty/pty_start.ts @@ -32,6 +32,8 @@ import { ChildProcess, exec, spawn } from "child_process"; import { commandStringToArray } from "../base/command_parser"; import { killProcess } from "../../../common/process_tools"; import GeneralStartCommand from "../general/general_start"; +import FunctionDispatcher from "../dispatcher"; +import StartCommand from "../start"; // 启动时错误异常 class StartupError extends Error { @@ -101,11 +103,13 @@ export default class PtyStartCommand extends InstanceCommand { const ptyParameter = ["-dir", instance.config.cwd, "-cmd", commandList.join(" "), "-size", `${instance.config.terminalOption.ptyWindowCol},${instance.config.terminalOption.ptyWindowRow}`]; if (!fs.existsSync(ptyAppPath)) { - // return instance.failure(new StartupError("PTY 转发程序不存在,请勿使用 PTY 模式,请在终端设置中更改")); logger.info(`会话 ${source}: 请求开启实例,模式为 PTY 终端`); logger.warn("PTY 终端转发程序不存在,自动降级到普通启动模式"); - instance.println("WARN", "PTY 终端转发程序不存在,自动降级到普通启动模式"); - instance.forceExec(new GeneralStartCommand()); + instance.println("ERROR", "PTY 终端转发程序不存在,自动降级到普通启动模式"); + // 关闭 PTY 类型,重新配置实例功能组,重新启动实例 + instance.config.terminalOption.pty = false; + await instance.forceExec(new FunctionDispatcher()); + await instance.exec(new StartCommand()); return; }