mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-04-06 17:10:29 +08:00
Fix: InstanceDetail name & Docker cwd mount
This commit is contained in:
parent
21cfcdfcd4
commit
7f8128f994
1
common/global.d.ts
vendored
1
common/global.d.ts
vendored
@ -36,6 +36,7 @@ export interface IGlobalInstanceConfig {
|
||||
rconPort?: number;
|
||||
rconIp?: string;
|
||||
|
||||
// Old fields
|
||||
terminalOption: {
|
||||
haveColor: boolean;
|
||||
pty: boolean;
|
||||
|
@ -97,7 +97,13 @@ export default class DockerStartCommand extends InstanceCommand {
|
||||
return instance.failure(new StartupDockerProcessError($t("TXT_CODE_instance.dirNoE")));
|
||||
|
||||
// command parsing
|
||||
const commandList = commandStringToArray(instance.config.startCommand);
|
||||
let commandList: string[] = [];
|
||||
if (instance.config.startCommand.trim()) {
|
||||
commandList = commandStringToArray(instance.config.startCommand);
|
||||
} else {
|
||||
commandList = [];
|
||||
}
|
||||
|
||||
const cwd = instance.absoluteCwdPath();
|
||||
|
||||
// parsing port open
|
||||
@ -180,24 +186,25 @@ export default class DockerStartCommand extends InstanceCommand {
|
||||
throw new Error($t("TXT_CODE_instance.invalidContainerName", { v: containerName }));
|
||||
}
|
||||
|
||||
// Whether to use TTY mode
|
||||
const isTty = instance.config.terminalOption.pty;
|
||||
const workingDir = instance.config.docker.workingDir ?? "/workspace/";
|
||||
|
||||
// output startup log
|
||||
logger.info("----------------");
|
||||
logger.info(`Session ${source}: Request to start an instance`);
|
||||
logger.info(`UUID: [${instance.instanceUuid}] [${instance.config.nickname}]`);
|
||||
logger.info(`NAME: [${containerName}]`);
|
||||
logger.info(`COMMAND: ${commandList.join(" ")}`);
|
||||
logger.info(`WORKSPACE: ${cwd}`);
|
||||
logger.info(`CWD: ${cwd}`);
|
||||
logger.info(`NET_MODE: ${instance.config.docker.networkMode}`);
|
||||
logger.info(`OPEN_PORT: ${JSON.stringify(publicPortArray)}`);
|
||||
logger.info(`EXT_MOUNT: ${JSON.stringify(extraBinds)}`);
|
||||
logger.info(`BINDS: ${JSON.stringify([`${cwd}:${workingDir}`, ...extraBinds])}`);
|
||||
logger.info(`NET_ALIASES: ${JSON.stringify(instance.config.docker.networkAliases)}`);
|
||||
logger.info(`MEM_LIMIT: ${maxMemory} MB`);
|
||||
logger.info(`MEM_LIMIT: ${maxMemory || "--"} MB`);
|
||||
logger.info(`TYPE: Docker Container`);
|
||||
logger.info("----------------");
|
||||
|
||||
// Whether to use TTY mode
|
||||
const isTty = instance.config.terminalOption.pty;
|
||||
|
||||
// Start Docker container creation and running
|
||||
const docker = new Docker();
|
||||
const container = await docker.createContainer({
|
||||
@ -209,14 +216,14 @@ export default class DockerStartCommand extends InstanceCommand {
|
||||
AttachStderr: true,
|
||||
Tty: isTty,
|
||||
User: `${processUserUid()}:${processGroupGid()}`,
|
||||
WorkingDir: "/workspace/",
|
||||
Cmd: commandList,
|
||||
WorkingDir: workingDir,
|
||||
Cmd: commandList ? commandList : undefined,
|
||||
OpenStdin: true,
|
||||
StdinOnce: false,
|
||||
ExposedPorts: exposedPorts,
|
||||
HostConfig: {
|
||||
Memory: maxMemory,
|
||||
Binds: [`${cwd}:/workspace/`, ...extraBinds],
|
||||
Binds: [`${cwd}:${workingDir}`, ...extraBinds],
|
||||
AutoRemove: true,
|
||||
CpusetCpus: cpusetCpus,
|
||||
CpuPeriod: cpuPeriod,
|
||||
|
@ -64,7 +64,8 @@ export default class InstanceConfig implements IGlobalInstanceConfig {
|
||||
cpuUsage: null,
|
||||
maxSpace: null,
|
||||
io: null,
|
||||
network: null
|
||||
network: null,
|
||||
workingDir: "/workspace/"
|
||||
};
|
||||
|
||||
public pingConfig = {
|
||||
|
@ -14,6 +14,7 @@ export interface IDockerConfig {
|
||||
networkAliases: string[];
|
||||
cpusetCpus: string; // CPU allowed to execute (eg 0-3, , 0, 1)
|
||||
cpuUsage: number;
|
||||
workingDir: string;
|
||||
}
|
||||
|
||||
// Instance specific process interface
|
||||
|
@ -23,7 +23,7 @@ import TermConfig from "./dialogs/TermConfig.vue";
|
||||
import EventConfig from "./dialogs/EventConfig.vue";
|
||||
import PingConfig from "./dialogs/PingConfig.vue";
|
||||
import RconSettings from "./dialogs/RconSettings.vue";
|
||||
import InstanceDetails from "./dialogs/InstanceDetails.vue";
|
||||
import InstanceDetail from "./dialogs/InstanceDetail.vue";
|
||||
import { GLOBAL_INSTANCE_NAME } from "../../config/const";
|
||||
import type { RouteLocationPathRaw } from "vue-router";
|
||||
import { TYPE_UNIVERSAL, TYPE_WEB_SHELL } from "../../hooks/useInstance";
|
||||
@ -32,7 +32,7 @@ const terminalConfigDialog = ref<InstanceType<typeof TermConfig>>();
|
||||
const rconSettingsDialog = ref<InstanceType<typeof RconSettings>>();
|
||||
const eventConfigDialog = ref<InstanceType<typeof EventConfig>>();
|
||||
const pingConfigDialog = ref<InstanceType<typeof PingConfig>>();
|
||||
const instanceDetailsDialog = ref<InstanceType<typeof InstanceDetails>>();
|
||||
const instanceDetailsDialog = ref<InstanceType<typeof InstanceDetail>>();
|
||||
|
||||
const { toPage: toOtherPager } = useAppRouters();
|
||||
|
||||
@ -221,7 +221,7 @@ const btns = computed(() =>
|
||||
@update="refreshInstanceInfo"
|
||||
/>
|
||||
|
||||
<InstanceDetails
|
||||
<InstanceDetail
|
||||
ref="instanceDetailsDialog"
|
||||
:instance-info="instanceInfo"
|
||||
:instance-id="instanceId"
|
||||
|
Loading…
x
Reference in New Issue
Block a user