diff --git a/app.js b/app.js index a43438d..0ff7aec 100644 --- a/app.js +++ b/app.js @@ -282,6 +282,22 @@ app.use("/fs", require("./onlinefs/controller/function")); if (MCSERVER.allError <= 0) { MCSERVER.infoLog("INFO", "控制面板已经启动"); + // 异步等待3秒,打开已配置打开 MCSM 时自启的服务器 + setTimeout(() => { + var serverModel = require("./model/ServerModel"); + let servers = serverModel.ServerManager().getServerObjects(); + for (let k in servers) { + try { + let server = servers[k]; + if (server.dataModel.autoStart) { + server.start(); + } + } catch (serverErr) { + MCSERVER.error("自动开启某服务器失败:", serverErr); + continue; + } + } + }, 3000); } else { MCSERVER.infoLog("INFO", "控制面板启动异常"); } diff --git a/core/Process/Mcserver.js b/core/Process/Mcserver.js index 70b46c4..8678014 100644 --- a/core/Process/Mcserver.js +++ b/core/Process/Mcserver.js @@ -24,6 +24,7 @@ class MinecraftServer extends ServerProcess { this.dataModel.oe = SYSTEM_CODE; this.dataModel.autoRestart = false; //是否自动重启 + this.dataModel.autoStart = false; //是否自动启动 this.dataModel.schedule = []; //计划任务配置项目 this.properties = undefined; //服务端配置表 diff --git a/public/template/component/console.html b/public/template/component/console.html index c0eae03..cc61c9b 100644 --- a/public/template/component/console.html +++ b/public/template/component/console.html @@ -78,6 +78,25 @@ +