forked from mirror/MCSM-Daemon
Feat: add ctrl+c func
This commit is contained in:
parent
8caafc1bf4
commit
da14b39868
@ -11,8 +11,8 @@ export default class PtyStopCommand extends InstanceCommand {
|
||||
}
|
||||
|
||||
async exec(instance: Instance) {
|
||||
const stopCommand = instance.config.stopCommand;
|
||||
if (stopCommand.toLocaleLowerCase() == "^c") return instance.failure(new Error($t("pty_stop.ctrlC")));
|
||||
let stopCommand = instance.config.stopCommand;
|
||||
if (stopCommand.toLocaleLowerCase() == "^c") stopCommand = "\x03";
|
||||
|
||||
if (instance.status() === Instance.STATUS_STOP || !instance.process) return instance.failure(new Error($t("pty_stop.notRunning")));
|
||||
instance.status(Instance.STATUS_STOPPING);
|
||||
|
@ -144,7 +144,6 @@ export default {
|
||||
},
|
||||
// src\entity\commands\pty\pty_stop.ts
|
||||
pty_stop: {
|
||||
ctrlC: "仿真终端无法使用Ctrl+C命令关闭进程,请重新设置关服命令",
|
||||
notRunning: "实例未处于运行中状态,无法进行停止.",
|
||||
execCmd: "已执行预设的关闭命令:{{stopCommand}}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令,比如 exit,stop,end 等",
|
||||
stopErr:
|
||||
|
@ -301,17 +301,6 @@ routerApp.on("instance/stop_asynchronous", (ctx, data) => {
|
||||
protocol.msg(ctx, "instance/stop_asynchronous", true);
|
||||
});
|
||||
|
||||
// send data stream to application instance
|
||||
routerApp.on("instance/stdin", (ctx, data) => {
|
||||
// This route uses a low-compatibility and direct and original way to write data
|
||||
// because this route will receive every character
|
||||
const instance = InstanceSubsystem.getInstance(data.instanceUuid);
|
||||
try {
|
||||
if (data.ch == "\r") return instance.process.write("\n");
|
||||
instance.process.write(data.ch);
|
||||
} catch (err) {}
|
||||
});
|
||||
|
||||
routerApp.on("instance/process_config/list", (ctx, data) => {
|
||||
const instanceUuid = data.instanceUuid;
|
||||
const files = data.files;
|
||||
|
@ -53,9 +53,7 @@ routerApp.on("stream/auth", (ctx, data) => {
|
||||
// Cancel forwarding events when registration is disconnected
|
||||
ctx.socket.on("disconnect", () => {
|
||||
InstanceSubsystem.stopForward(instance.instanceUuid, ctx.socket);
|
||||
logger.info(
|
||||
$t("stream_router.disconnect", { id: ctx.socket.id, address: ctx.socket.handshake.address, uuid: instance.instanceUuid })
|
||||
);
|
||||
logger.info($t("stream_router.disconnect", { id: ctx.socket.id, address: ctx.socket.handshake.address, uuid: instance.instanceUuid }));
|
||||
});
|
||||
protocol.response(ctx, true);
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user