Feat: 统一文案口径

This commit is contained in:
Suwings 2022-07-17 11:23:59 +08:00
parent 6083435df2
commit abaf6f7dc6
5 changed files with 16 additions and 8 deletions

View File

@ -153,7 +153,7 @@ ${instance.config.startCommand}
${JSON.stringify(ptyParameter)}
仿仿
`
);
throw new StartupError("实例启动失败,请检查启动命令,主机环境和配置文件等");

View File

@ -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如果无法关闭实例请前往实例设置更改关闭实例的正确命令比如 exitstopend 等`);
instance.println(
"INFO",
`已执行预设的关闭命令:${stopCommand}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令比如 exitstopend 等`
);
// 若 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);

View File

@ -51,7 +51,7 @@ export default class InstanceConfig {
public terminalOption = {
haveColor: false,
pty: true,
ptyWindowCol: 80,
ptyWindowCol: 140,
ptyWindowRow: 40
};

View File

@ -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<string, string>();

View File

@ -109,7 +109,7 @@ routerApp.on("stream/input", async (ctx, data) => {
}
});
// 处理终端输入,适用于终端的直连输入输出流。
// 处理终端输入,适用于仿真终端的直连输入输出流。
routerApp.on("stream/write", async (ctx, data) => {
try {
const buf = data.input;