From abaf6f7dc6f0e6f50752e46987925a2bfbca8392 Mon Sep 17 00:00:00 2001 From: Suwings Date: Sun, 17 Jul 2022 11:23:59 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20=E7=BB=9F=E4=B8=80=E6=96=87=E6=A1=88?= =?UTF-8?q?=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entity/commands/pty/pty_start.ts | 2 +- src/entity/commands/pty/pty_stop.ts | 16 ++++++++++++---- src/entity/instance/Instance_config.ts | 2 +- src/routers/instance_event_router.ts | 2 +- src/routers/stream_router.ts | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/entity/commands/pty/pty_start.ts b/src/entity/commands/pty/pty_start.ts index bb6b93e..979c4ef 100644 --- a/src/entity/commands/pty/pty_start.ts +++ b/src/entity/commands/pty/pty_start.ts @@ -153,7 +153,7 @@ ${instance.config.startCommand} 参数:${JSON.stringify(ptyParameter)} 请将此信息报告给管理员,技术人员或自行排查故障。 -如果您认为是面板伪终端导致的问题,请在左侧终端设置中关闭“伪终端”选项,我们将会采用原始输入输出流的方式监听程序。 +如果您认为是面板仿真终端导致的问题,请在左侧终端设置中关闭“仿真终端”选项,我们将会采用原始输入输出流的方式监听程序。 ` ); throw new StartupError("实例启动失败,请检查启动命令,主机环境和配置文件等"); diff --git a/src/entity/commands/pty/pty_stop.ts b/src/entity/commands/pty/pty_stop.ts index 0b02cd4..9fd8a3e 100644 --- a/src/entity/commands/pty/pty_stop.ts +++ b/src/entity/commands/pty/pty_stop.ts @@ -30,20 +30,28 @@ export default class PtyStopCommand extends InstanceCommand { async exec(instance: Instance) { const stopCommand = instance.config.stopCommand; - if (stopCommand.toLocaleLowerCase() == "^c") return instance.failure(new Error("伪终端无法使用^C命令关闭进程,请重新设置关服命令")); + if (stopCommand.toLocaleLowerCase() == "^c") + return instance.failure(new Error("仿真终端无法使用Ctrl+C命令关闭进程,请重新设置关服命令")); - if (instance.status() === Instance.STATUS_STOP || !instance.process) return instance.failure(new Error("实例未处于运行中状态,无法进行停止")); + if (instance.status() === Instance.STATUS_STOP || !instance.process) + return instance.failure(new Error("实例未处于运行中状态,无法进行停止")); instance.status(Instance.STATUS_STOPPING); await instance.exec(new SendCommand(stopCommand)); - instance.println("INFO", `已执行预设的关闭命令:${stopCommand}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令,比如 exit,stop,end 等`); + instance.println( + "INFO", + `已执行预设的关闭命令:${stopCommand}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令,比如 exit,stop,end 等` + ); // 若 10 分钟后实例还处于停止中状态,则恢复状态 const cacheStartCount = instance.startCount; setTimeout(() => { if (instance.status() === Instance.STATUS_STOPPING && instance.startCount === cacheStartCount) { - instance.println("ERROR", "关闭命令已发出但长时间未能关闭实例,可能是实例关闭命令错误或实例进程假死导致,现在将恢复到运行中状态,可使用强制终止指令结束进程。"); + instance.println( + "ERROR", + "关闭命令已发出但长时间未能关闭实例,可能是实例关闭命令错误或实例进程假死导致,现在将恢复到运行中状态,可使用强制终止指令结束进程。" + ); instance.status(Instance.STATUS_RUNNING); } }, 1000 * 60 * 10); diff --git a/src/entity/instance/Instance_config.ts b/src/entity/instance/Instance_config.ts index f099873..36d5453 100644 --- a/src/entity/instance/Instance_config.ts +++ b/src/entity/instance/Instance_config.ts @@ -51,7 +51,7 @@ export default class InstanceConfig { public terminalOption = { haveColor: false, pty: true, - ptyWindowCol: 80, + ptyWindowCol: 140, ptyWindowRow: 40 }; diff --git a/src/routers/instance_event_router.ts b/src/routers/instance_event_router.ts index 9cacf24..27f1759 100644 --- a/src/routers/instance_event_router.ts +++ b/src/routers/instance_event_router.ts @@ -25,7 +25,7 @@ import RouterContext from "../entity/ctx"; import * as protocol from "../service/protocol"; import InstanceSubsystem from "../service/system_instance"; import fs from "fs-extra"; -const MAX_LOG_SIZE = 1024; +const MAX_LOG_SIZE = 512; // 缓存区 const buffer = new Map(); diff --git a/src/routers/stream_router.ts b/src/routers/stream_router.ts index 0284de3..647b517 100644 --- a/src/routers/stream_router.ts +++ b/src/routers/stream_router.ts @@ -109,7 +109,7 @@ routerApp.on("stream/input", async (ctx, data) => { } }); -// 处理终端输入,适用于伪终端的直连输入输出流。 +// 处理终端输入,适用于仿真终端的直连输入输出流。 routerApp.on("stream/write", async (ctx, data) => { try { const buf = data.input;