Optimize: Annotation text

This commit is contained in:
unitwk 2022-11-15 20:30:21 +08:00
parent 326b6873d0
commit 2c3b47eb89
3 changed files with 22 additions and 26 deletions

View File

@ -34,7 +34,7 @@ _ /_/ // /_/ // __/ / / / / / /_/ / / / /
globalConfiguration.load();
const config = globalConfiguration.config;
// set language
// Set language
if (fs.existsSync(LOCAL_PRESET_LANG_PATH)) {
i18next.changeLanguage(fs.readFileSync(LOCAL_PRESET_LANG_PATH, "utf-8"));
} else {
@ -52,7 +52,7 @@ import { initDependent } from "./service/install";
import "./service/async_task_service";
import "./service/async_task_service/quick_install";
// initialize optional dependencies asynchronously
// Initialize optional dependencies
initDependent();
// Initialize HTTP service
@ -80,7 +80,7 @@ const io = new Server(httpServer, {
}
});
// Initialize application instance system & load application instance
// Initialize application instance system
try {
InstanceSubsystem.loadInstances();
logger.info($t("app.instanceLoad", { n: InstanceSubsystem.instances.size }));
@ -89,18 +89,13 @@ try {
process.exit(-1);
}
// Register for Websocket connection events
// Initialize Websocket server
io.on("connection", (socket: Socket) => {
logger.info($t("app.sessionConnect", { ip: socket.handshake.address, uuid: socket.id }));
// Join the global Socket object
protocol.addGlobalSocket(socket);
// Socket.io request is forwarded to the custom routing controller
router.navigation(socket);
// Disconnect event
// Remove from the global Socket object
socket.on("disconnect", () => {
protocol.delGlobalSocket(socket);
for (const name of socket.eventNames()) socket.removeAllListeners(name);
@ -127,9 +122,6 @@ logger.info($t("app.exitTip"));
logger.info("----------------------------");
console.log("");
// Load the terminal interface UI
// import "./service/ui";
["SIGTERM", "SIGINT", "SIGQUIT"].forEach(function (sig) {
process.on(sig, async function () {
try {

View File

@ -0,0 +1,15 @@
// Copyright (C) 2022 MCSManager <mcsmanager-dev@outlook.com>
import { ILifeCycleTask } from "../../instance/life_cycle";
import Instance from "../../instance/instance";
import KillCommand from "../kill";
// When the instance is running, continue to check the expiration time
export default class TimeCheck implements ILifeCycleTask {
public status: number = 0;
public name: string = "openfrp";
async start(instance: Instance) {}
async stop(instance: Instance) {}
}

View File

@ -27,38 +27,28 @@ interface IInstanceInfo {
// instance class
export default class Instance extends EventEmitter {
// instance class state constants
public static readonly STATUS_BUSY = -1;
public static readonly STATUS_STOP = 0;
public static readonly STATUS_STOPPING = 1;
public static readonly STATUS_STARTING = 2;
public static readonly STATUS_RUNNING = 3;
// instance type constant
public static readonly TYPE_UNIVERSAL = "universal"; // Universal input and output program
public static readonly TYPE_UNIVERSAL = "universal";
public static readonly TYPE_MINECRAFT_JAVA = "minecraft/java";
public static readonly TYPE_MINECRAFT_BEDROCK = "minecraft/bedrock";
// Minecraft server type
public static readonly TYPE_MINECRAFT_JAVA = "minecraft/java"; // Universal server for Minecraft PC version
public static readonly TYPE_MINECRAFT_BEDROCK = "minecraft/bedrock"; // Minecraft Bedrock Edition
// Instance basic properties, no need to persist
public instanceStatus: number;
public instanceUuid: string;
public lock: boolean;
public startCount: number;
public startTimestamp: number = 0;
// ongoing asynchronous task
public asynchronousTask: IExecutable = null;
// Life cycle tasks, timed task manager
public readonly lifeCycleTaskManager = new LifeCycleTaskManager(this);
// default command manager
public readonly presetCommandManager = new PresetCommandManager(this);
// The instance needs to be persisted and used as the configured entity class
public config: InstanceConfig;
// The instance does not need to persist the specific information saved
public info: IInstanceInfo = {
currentPlayers: -1,
maxPlayers: -1,
@ -67,7 +57,6 @@ export default class Instance extends EventEmitter {
playersChart: []
};
// the real process of the instance
public process: IInstanceProcess;
// When initializing an instance, the instance must be initialized through uuid and configuration class, otherwise the instance will be unavailable