新增 手动关服时忽略崩溃重启

This commit is contained in:
Suwings 2019-01-15 14:17:35 +08:00
parent 9f50a94174
commit 559a259d19
5 changed files with 37 additions and 15 deletions

View File

@ -240,6 +240,7 @@ class ServerProcess extends EventEmitter {
if (this._run == true) {
this.send('stop');
this.send('end');
this.send('exit');
//开始计时重启
let timeCount = 0;

View File

@ -35,7 +35,7 @@
</div>
</transition>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toCommand('stop');toCommand('end')" v-if="run">
<div class="PanelItem" v-on:click="toCommand('__stop__')" v-if="run">
<span class="glyphicon glyphicon-pause" aria-hidden="true"> </span> 关闭服务器
</div>
</transition>

View File

@ -112,15 +112,7 @@
].join(" ");
},
stopServer: function () {
this.toCommand('stop');
this.toCommand('end');
this.toCommand('exit');
var that = this;
setTimeout(function () {
that.toCommand('stop');
that.toCommand('end');
that.toCommand('exit');
}, 2000);
this.toCommand('__stop__');
}
},
data: {

View File

@ -53,6 +53,9 @@ serverModel.ServerManager().on('exit', (data) => {
selectWebsocket(data.serverName,
(socket) => response.wsMsgWindow(socket.ws, '服务器关闭'));
//下一个事件
serverModel.ServerManager().emit("exit_next", data);
})
//服务器开启

View File

@ -17,20 +17,46 @@ WebSocketObserver().listener('server/console/command', (data) => {
if (command == '__restart__') {
serverModel.ServerManager().getServer(serverName).restart();
response.wsMsgWindow(data.ws, '服务器正在重启..');
//return
return
}
//强制结束服务端进程
if (command == '__killserver__') {
serverModel.ServerManager().getServer(serverName).kill();
response.wsMsgWindow(data.ws, '服务器结束进程');
return
}
//通过命令方法停止服务端
if (command == '__stop__') {
let server = serverModel.ServerManager().getServer(serverName);
let isRestart = server.dataModel.autoRestart;
if (isRestart) {
server.dataModel.autoRestart = false;
server._onceStopRestart = true;
}
//使用三种可能的命令按照顺序进行发送
serverModel.sendCommand(serverName, 'stop');
serverModel.sendCommand(serverName, 'end');
serverModel.sendCommand(serverName, 'exit');
return
}
//不是特殊命令,则直接执行
try {
serverModel.sendCommand(serverName, command);
} catch (e) {
throw e;
} catch (err) {
throw err;
}
return;
}
response.wsSend(data.ws, 'server/console/command', null);
});
});
//服务端退出之后第一事件
//当服务端开启自动崩溃重启后,手动关闭服务端时将忽略临时重启规则
serverModel.ServerManager().on('exit_next', (data) => {
let server = serverModel.ServerManager().getServer(data.serverName);
if (server._onceStopRestart) {
server.dataModel.autoRestart = true;
server._onceStopRestart = false;
}
})