mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-02-17 15:59:41 +08:00
Feat: delete pty install
This commit is contained in:
parent
be75b8de2d
commit
2dcacc6b6a
@ -51,7 +51,6 @@ import * as router from "./service/router";
|
||||
import * as koa from "./service/http";
|
||||
import * as protocol from "./service/protocol";
|
||||
import InstanceSubsystem from "./service/system_instance";
|
||||
import { initDependent } from "./service/install";
|
||||
import "./service/async_task_service";
|
||||
import "./service/async_task_service/quick_install";
|
||||
import "./service/system_visual_data";
|
||||
@ -86,9 +85,6 @@ const io = new Server(httpServer, {
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize optional dependencies
|
||||
initDependent();
|
||||
|
||||
// Initialize application instance system
|
||||
try {
|
||||
InstanceSubsystem.loadInstances();
|
||||
|
@ -1,58 +0,0 @@
|
||||
import { $t } from "../i18n";
|
||||
import os from "os";
|
||||
import fs from "fs-extra";
|
||||
import https from "https";
|
||||
import path from "path";
|
||||
import logger from "./log";
|
||||
import { downloadFileToLocalFile } from "./download";
|
||||
|
||||
const PTY_NAME = `pty_${os.platform()}_${os.arch()}${os.platform() === "win32" ? ".exe" : ""}`;
|
||||
const PTY_PATH = path.normalize(path.join(process.cwd(), "lib", PTY_NAME));
|
||||
const PTY_DIR_PATH = path.join(process.cwd(), "lib");
|
||||
|
||||
function ptyChmod() {
|
||||
try {
|
||||
fs.chmodSync(PTY_PATH, 0o755);
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.warn($t("TXT_CODE_install.changeModeErr", { path: PTY_PATH }));
|
||||
fs.remove(PTY_PATH, () => {});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function installPty(url: string): Promise<boolean> {
|
||||
if (!fs.existsSync(PTY_DIR_PATH)) fs.mkdirsSync(PTY_DIR_PATH);
|
||||
if (fs.existsSync(PTY_PATH) && fs.statSync(PTY_PATH)?.size > 1024) {
|
||||
if (!ptyChmod()) throw new Error("ptyChmod error");
|
||||
logger.info($t("TXT_CODE_install.ptySupport"));
|
||||
return true;
|
||||
}
|
||||
await downloadFileToLocalFile(url, PTY_PATH);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Emulate terminal-dependent programs, PTY programs based on Go/C++
|
||||
// Reference: https://github.com/MCSManager/pty
|
||||
export function initDependent() {
|
||||
const ptyUrls = [`https://mcsmanager.oss-cn-guangzhou.aliyuncs.com/${PTY_NAME}`];
|
||||
function setup(index = 0) {
|
||||
installPty(ptyUrls[index])
|
||||
.then(() => {
|
||||
logger.info($t("TXT_CODE_install.installed"));
|
||||
logger.info($t("TXT_CODE_install.guide"));
|
||||
ptyChmod();
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
fs.remove(PTY_PATH, () => {});
|
||||
if (index === ptyUrls.length - 1) {
|
||||
logger.warn($t("TXT_CODE_install.installErr"));
|
||||
if (err?.message) logger.warn(err.message);
|
||||
return;
|
||||
}
|
||||
return setup(index + 1);
|
||||
});
|
||||
}
|
||||
|
||||
setup(0);
|
||||
}
|
@ -160,7 +160,7 @@
|
||||
"TXT_CODE_pty_start.instanceUuid": "Instance UUID: [{{instanceUuid}}]",
|
||||
"TXT_CODE_pty_start.mustAbsolutePath": "The working directory for emulated terminal must be an absolute path. Please go to the instance settings and set the working directory to an absolute path.",
|
||||
"TXT_CODE_pty_start.notSupportPty": "Emulated terminal mode failed. Unsupported architecture or system. Downgraded to regular terminal mode...",
|
||||
"TXT_CODE_pty_start.pidErr": "Detected instance process/container startup failure (PID is empty). Possible reasons include:\n1. Incorrect instance startup command. Please check the startup command and parameters in settings.\n2. Incorrect system host environment or missing dependencies, such as Java environment, etc.\n\nNative startup command:\n{{startCommand}}\n\nEmulated terminal relay command:\nProgram: {{path}}\nParameters: {{params}}\n\nPlease report this information to the administrator, technical support, or troubleshoot it yourself.\nIf you believe the issue is caused by the panel's emulated terminal, please disable the 'Emulated Terminal' option in the left-side of terminal settings. We will use the original input and output streams to monitor the program.",
|
||||
"TXT_CODE_pty_start.pidErr": "It was detected that the process startup failed. The possible reasons are: \n1. The instance startup command was written incorrectly. Please go to the instance setting interface to check the startup command and parameters. \n2. The system host environment is incorrect or lacks an environment, such as a lack of Java environment, etc. \n\nStart command:\n{{startCommand}}\n\nPlease report this information to the administrator, technician or troubleshoot yourself.",
|
||||
"TXT_CODE_pty_start.ptyCwd": "Working Directory: {{cwd}}",
|
||||
"TXT_CODE_pty_start.ptyParams": "PTY Parameters: {{param}}",
|
||||
"TXT_CODE_pty_start.ptyPath": "PTY Path: {{path}}",
|
||||
|
@ -160,7 +160,7 @@
|
||||
"TXT_CODE_pty_start.instanceUuid": "实例标识符: [{{instanceUuid}}]",
|
||||
"TXT_CODE_pty_start.mustAbsolutePath": "仿真终端启动工作目录必须使用绝对路径,请前往实例设置界面重新设置工作路径为绝对路径",
|
||||
"TXT_CODE_pty_start.notSupportPty": "仿真终端模式失败,无法支持的架构或系统,已自动降级到普通终端模式...",
|
||||
"TXT_CODE_pty_start.pidErr": "检测到实例进程/容器启动失败(PID 为空),其可能的原因是:\n1. 实例启动命令编写错误,请前往实例设置界面检查启动命令与参数。\n2. 系统主机环境不正确或缺少环境,如 Java 环境等。\n\n原生启动命令:\n{{startCommand}}\n\n仿真终端中转命令:\n程序:{{path}}\n参数:{{params}}\n\n请将此信息报告给管理员,技术人员或自行排查故障。\n如果您认为是面板仿真终端导致的问题,请在左侧终端设置中关闭“仿真终端”选项,我们将会采用原始输入输出流的方式监听程序。",
|
||||
"TXT_CODE_pty_start.pidErr": "检测到进程启动失败,其可能的原因是:\n1. 实例启动命令编写错误,请前往实例设置界面检查启动命令与参数。\n2. 系统主机环境不正确或缺少环境,比如缺少 Java 环境等。\n\n启动命令:\n{{startCommand}}\n\n请将此信息报告给管理员,技术人员或自行排查故障。",
|
||||
"TXT_CODE_pty_start.ptyCwd": "工作目录: {{cwd}}",
|
||||
"TXT_CODE_pty_start.ptyParams": "PTY 参数: {{param}}",
|
||||
"TXT_CODE_pty_start.ptyPath": "PTY 路径: {{path}}",
|
||||
|
Loading…
Reference in New Issue
Block a user