forked from mirror/MCSM-Daemon
解决了按需启动因为socket关闭回调无法触发可能导致假死无法唤醒的问题
This commit is contained in:
parent
672c7fc340
commit
e173e8abcd
@ -67,14 +67,13 @@ export class OnDemandRunner {
|
||||
// create socket server
|
||||
this.socketServer = this.startSocketServer(port);
|
||||
// waiting for player connect then close socket server
|
||||
await new Promise<void>((ok, reject) => {
|
||||
this.socketServer.on('close', () => {
|
||||
ok();
|
||||
while (this.socketServer.listening) {
|
||||
await new Promise<void>((ok) => {
|
||||
setTimeout(ok, 2000);
|
||||
});
|
||||
this.socketServer.on('error', (error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
logger.info(`${this.instance.instanceUuid} `, $t("on_demand.playerConnected"));
|
||||
this.instance.println("INFO", $t("on_demand.playerConnected"));
|
||||
this.socketServer = null;
|
||||
}
|
||||
resolve();
|
||||
|
@ -228,6 +228,7 @@
|
||||
"cantStartOnDemand": "May not a Minecraft server, unable to start on demand.",
|
||||
"over30minClose": "Instance has been vancant for more than 30 minutes, going to sleep...",
|
||||
"instanceSleeping": "Instance is sleeping, waiting for player to wake it up.",
|
||||
"playerConnected": "Connection recived, waking up instance...",
|
||||
"start": "On demand sequence started.",
|
||||
"stop": "On demand sequence stopped."
|
||||
}
|
||||
|
@ -228,6 +228,7 @@
|
||||
"cantStartOnDemand": "可能由于不是Minecraft服务器,无法使用按需启动功能。",
|
||||
"over30minClose": "实例超过30分钟不活跃,正在进入休眠状态。",
|
||||
"instanceSleeping": "实例已休眠,等待玩家唤醒。",
|
||||
"playerConnected": "检测到连接请求,正在唤醒实例。",
|
||||
"start": "已进入按需启动模式,实例将在超过30分钟不活跃后自动关闭并在玩家进入时自动开启。",
|
||||
"stop": "已退出按需启动模式。"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user